About Dialog Boxes

Jul 11, 2011 at 10:57 PM

I am not being able to use the DataWindow you provide with Catel (I have read it's a .NET 4 issue, I think).

So. I am using regular Windows/Dialog Boxes through the UI Service Catel provides. Said so... here comes the question:

What "MVVM" way supported by Catel do u suggest to set the Owner's Dialog Box?

Thanks in advance.

Coordinator
Jul 12, 2011 at 6:52 AM

Why can't you use the DataWindow? The data window constructor has lots of overrides. One of the overrides accepts a parameter determining whether the owner should be set. If true (default behavior), the window sets it's owner which is the main window of the application.

If you need other behavior, please let us know what kind of behavior you need.

Jul 12, 2011 at 11:56 AM

Every  time I attempt to use a DataWindow, The client area shows at minimum size regardless the client's content.

Any suggestion?

Thank you.

Coordinator
Jul 12, 2011 at 1:36 PM

Strange, can you show some code using the data window (xaml only please) while showing a textblock with Hello World?

Jul 12, 2011 at 2:35 PM

He comes the XAML. It's good to notice that even I'm forcing Width an Height for the window, this is ignored and the client area doesn't show up properly

I'm currently using Catel (for 3.5) and .NET 4. 

Thank you. 

<

Catel:DataWindow x:Class="MyNS.Views.HelloWorldWindow"

 

xmlns

="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

 

xmlns:x

="http://schemas.microsoft.com/winfx/2006/xaml"

 

xmlns:BasicViewModel

="clr-namespace:MyNS.ViewModels"

 

xmlns:Catel

="clr-namespace:Catel.Windows;assembly=Catel.Windows"

 

x:TypeArguments="BasicViewModel:HelloWorldViewModel" Width="300" Height

="300">

<StackPanel>

<TextBox Text="{Binding Title}" />

 <

/StackPanel>

</

Catel:DataWindow>

Coordinator
Jul 12, 2011 at 6:26 PM

The Width and Height are ignored because by default, the DataWindow sets the SizeToContent to WidthAndHeight (that should've been default behavior of the window). If you don't want this behavior, just set it to manual by yourself in the xaml and it will accept the size you set.

The window also automatically sets ShowInTaskbar to false because there are very few windows that actually should be visible in the taskbar (main window, non-modal dialogs, etc). Still it's weird that it is not showing up (the TextBox should at least take some space, although it's not a lot.

Can you verify if the above feedback is helpful for you? If not, I will try to figure out why it is not working with you (it should, I have several examples available working here in .NET 40).

Jul 12, 2011 at 7:25 PM

I have updated the XAML by adding SizeToContent=Manual and keeping Width and Height

Te problem still persists.

Thanks again.

Coordinator
Jul 13, 2011 at 4:57 AM

I've sent you an e-mail with a demo project, please try that one. If it still doesn't work, please send me a demo project so I can take a look at it.

Jul 13, 2011 at 1:07 PM

Thank you very much for the demo.

I have tested it and works as expected.

I have checked my proyect too, and the possibles differences I notice are:

1, Both windows in your project inherits from DataWindow. (in my project the main window is a regular WPF Window [ is it relevant? ]

2. I haven't checked yet... but perhaps the Catel library's version.

I'll make a demo with the same dll's you sent me and if doesn't work I'll send it back to you.

Thank you very much...

 

 

 

Coordinator
Jul 13, 2011 at 8:23 PM

1) Shouldn't make a difference

2) Shouldn't make a difference either

But, it would be great if you could post feedback as soon as you have found out the issue, it might help out others as well. 

Jul 14, 2011 at 2:32 PM

At any moment I will send you feedback about this matter.

Thank you very much...

Coordinator
Jul 18, 2011 at 7:37 AM

Just sent you an e-mail, the InitializeComponent in the code-behind was commented.

Jul 18, 2011 at 11:38 AM

Now it's working fine. Thank you very much.

 

 

Jul 18, 2011 at 12:40 PM

Is there a way to hide/customize the DataWindow's InfoBarMessageControl?

Now I have 2 active, the DataWindow's default and my own control. I need either customize the default or hide it in order to keep my own.

Thank you.

Coordinator
Jul 18, 2011 at 12:46 PM
Edited Jul 18, 2011 at 12:47 PM

Yes, that is possible. 

There are lots of overrides for the base class. Some of them take the InfoBarMessageControlGenerationMode as input. There you can pass the InfoBarMessageControlGenerationMode.None value so none is generated.

 

For example:

public PersonWindow(PersonViewModel viewModel)
  : base(viewModel, DataWindowMode.OkCancel, DataWindowDefaultButton.OK, true, InfoBarMessageControlGenerationMode.Inline)

This generates a normal window with OK/Cancel button without the InfoBarMessageControl.

Jul 18, 2011 at 3:56 PM

I am trying to use the DataWindow class with my own buttons (in custom mode) .

I have a command from my main VM that opens, and show it in a modal way.

Every time I cancel the window I'm getting a strange behavior from my app (in this case, I have a DataGrid inside a main view showing some data. When I close the data window (by pressing the window's caption bar X, and thus I return to my main view ,it seems that the observable collection bound to the data grid gets cleared.

There is something the data window is doing that I'm missing.( I don't have this behavior with regular windows)

How can a route muy own Ok / Cancel buttons to the default commands, or how to disable this behavior and implement my own?



On the other hand... How to control the DataWindow DialogResult's property?

Thank you very much

 

Coordinator
Jul 18, 2011 at 4:07 PM

Are you defining the collection as model in the DataWindow? If so, it reverts the values if you cancel (close via cancel or cross) the window. You can disable this behavior by passing false to the supportIEditable parameter of the datawindow.