Hi,
It's not quite clear on how to use the XamDialogWindow. As such, the XamDialogWindow doesn't seem to be a normal" window replacement as it has to "live" into some container.
Let say I want to convert the following About dialog box to one using the XamDialogWindow, how would I do it?
<Window x:Class="Vizimax.Service.Client.Dialog.AboutDialog" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:res="clr-namespace:Vizimax.Service.Client.Resources" SizeToContent="WidthAndHeight" WindowStyle="ToolWindow" ResizeMode="NoResize" ShowInTaskbar="False" Title="{Binding Path=ApplicationName, StringFormat={x:Static res:Strings.AboutDialogTitle}}" MinHeight="100" MinWidth="300" > <Grid> <Grid.RowDefinitions> <RowDefinition Height="*"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Grid Grid.Row="0"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Image Grid.Row="0" Margin="10" Source="/Vizimax.Service.Client;component/Resources/Images/Logo.png" Stretch="None" HorizontalAlignment="Center" VerticalAlignment="Top" /> </Grid> <Grid Grid.Row="1"> <Grid.ColumnDefinitions> <ColumnDefinition Width="3*"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <Label Grid.Column="0" Content="{Binding Path=Version}" FontFamily="Verdana" FontSize="11"/> <Button Grid.Column="1" Margin="3" Content="{x:Static res:Strings.LabelOK}" IsDefault="True" Command="{Binding RelayCommandOK}"/> </Grid> </Grid></Window>
Hello Jean-Marc,
The xamDialogWindow control can be used as MessageBox rather than as a substitute of the native WPF Window .
The xamDialogWindow doesn’t provide properties as SizeToContent and ShowInTaskbar.
I’ve attached a sample application that uses transparent Window with WindowStyle="None" that mimics the required behavior.
Let me know if I may be of further assistance.
Hi Svetla,
Your example is to create all the controls programmatically. I would prefer to build the interface using the usual WPF/XAML tools. I did give it a try using a UserControl as shown below:
<UserControl x:Class="DialogWindow_MessageBox.MyUserControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:DialogWindow_MessageBox" xmlns:ig="http://schemas.infragistics.com/xaml" mc:Ignorable="d" > <Grid x:Name="LayoutRoot"> <ig:XamDialogWindow Width="200" Height="200" IsModal="True" StartupPosition="Center"> <ig:XamDialogWindow.Content> <StackPanel Orientation="Horizontal"> <Button Name="buttonOK" Content="Ok" Height="25" Width="50"/> <Button Name="buttonCancel" Content="Cancel" Height="25" Width="50"/> </StackPanel> </ig:XamDialogWindow.Content> </ig:XamDialogWindow> </Grid></UserControl>
Here is the code to use it:
private void Button_Click(object sender, RoutedEventArgs e) { _myUserControl = new MyUserControl(); _myUserControl += MyUserControlCloseEvent; windowContainer.Children.Add(_myUserControl);}private void MyUserControlCloseEvent(object sender, RoutedEventArgs e){ //Process dialog data... windowContainer.Children.Remove(_myUserControl); _myUserControl = null;}
As such this works but it is not a modal dialog proper which won't block the calling application.
Did you manage to achieve your requirements using the xamDialogWindow control?
You can check the Modal and Modeless Dialog Windows topic.
Let me know if you have any questions.
Hi Svetla.
The intent was to have modal dialog box that I could theme.
Finally, I used the XamRibbonWindow with only a RibbonWindowContentHost.Content section which suits me fine.
Thanks for your help.
As far as I understand a dialog window should appear when you close the main application window. Is that the user case? If this is the case, it won't be possible to achieve this with the xamDialogWindow control.
I am using the IsModal="True". However my point is that the XamDialogWindow is not a window proper. It needs to live in a container which is, in your examples, some application window.
When you create a modal dialog in WPF, you can then execute the following statements:
MyDialog myDialog = new MyDialog();
myDialog.ShowDialog();
... the ShowDialog() call will return only when the user closes the window.
For my application, I need this blocking.
Thanks for your help on this, JMD