In my Prism 6.2 WPF MVVM application I use notification and confirmation modal dialogs. Below is a definition of the View of a notification modal dialog used in my application:
<UserControl x:Class="CommonWpfControlLibrary.NotificationDialogPopupView"
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:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300" MaxHeight="300" MaxWidth="600">
<StackPanel Orientation="Vertical" Margin="20">
<TextBlock Text="{Binding Message}" TextWrapping="Wrap"/>
<telerik:RadButton Content="OK" Command="{Binding OnOkPressedCommand}" HorizontalAlignment="Center" Width="50" Margin="0 10 0 0"/>
</StackPanel>
</UserControl>
Below is the ViewModel of this dialog:
public class NotificationDialogPopupViewModel : BindableBase, IInteractionRequestAware
{
#region IInteractionRequestAware Implementation
public INotification Notification
{
get { return _notification; }
set
{
SetProperty(ref _notification, value as Notification);
OnPropertyChanged(() => Message);
}
}
public Action FinishInteraction { get; set; }
#endregion
#region Fields
private Notification _notification;
#endregion
#region Constructors
public NotificationDialogPopupViewModel()
{
this.OnOkPressedCommand = new DelegateCommand(OnOk);
}
#endregion
#region Properties
public string Message
{
get { return (_notification?.Content as string) ?? "null"; }
}
#endregion
#region Commands
public DelegateCommand OnOkPressedCommand { get; private set; }
private void OnOk()
{
FinishInteraction();
}
#endregion
}
And below is an example of how I use this dialog in my application. This is XAML from the View where I need to use the dialog:
<prism:InteractionRequestTrigger SourceObject="{Binding NotificationRequest, Mode=OneWay}">
<prism:PopupWindowAction IsModal="True" CenterOverAssociatedObject="True">
<prism:PopupWindowAction.WindowContent>
<commonControls:NotificationDialogPopupView/>
</prism:PopupWindowAction.WindowContent>
<prism:PopupWindowAction.WindowStyle>
<Style TargetType="Window">
<Setter Property="ResizeMode" Value="NoResize"/>
<Setter Property="SizeToContent" Value="WidthAndHeight"/>
</Style>
</prism:PopupWindowAction.WindowStyle>
</prism:PopupWindowAction>
</prism:InteractionRequestTrigger>
And this is the definition of method for visualizing of the dialog from the appropriate ViewModel where I need to use the dialog:
private void raiseNotification(string message, string caption)
{
this.NotificationRequest.Raise(
new Notification { Content = message, Title = caption },
n => { this.NotificationStatus = "The user was notified."; });
}
And finally, the example of the dialog itself:
This is the dialog with error message. But as you can see there is no 'Error' icon in the left part of the client area of the dialog. So that I have a question: How to add: 'Error' icon to a modal dialog containing an error mesage, 'Warning' icon to a modal dialog containing a warning message, and 'Notify' icon to a modal dialog containing a user-notifying message as it is implemented in WPF MessageBox modal dialogs? Please help.