`///
/// Initializes a new instance of the class.
///
public ModernDialog()
{
this.DefaultStyleKey = typeof(ModernDialog);
this.WindowStartupLocation = WindowStartupLocation.CenterOwner;
this.closeCommand = new RelayCommand(o => {
var result = o as MessageBoxResult?;
if (result.HasValue) {
this.messageBoxResult = result.Value;
if (System.Windows.Interop.ComponentDispatcher.IsThreadModal)//**....Here!!!**
{
// sets the Window.DialogResult as well, if windows is called by ShowDialog()
if (result.Value == MessageBoxResult.OK || result.Value == MessageBoxResult.Yes)
{
this.DialogResult = true;
}
else if (result.Value == MessageBoxResult.Cancel || result.Value == MessageBoxResult.No)
{
this.DialogResult = false;
}
else
{
this.DialogResult = null;
}
}
}
Close();
});
this.Buttons = new Button[] { this.CloseButton };
// set the default owner to the app main window (if possible)
if (Application.Current != null && Application.Current.MainWindow != this) {
this.Owner = Application.Current.MainWindow;
}
}`
`///
/// Initializes a new instance of the class.
///
public ModernDialog()
{
this.DefaultStyleKey = typeof(ModernDialog);
this.WindowStartupLocation = WindowStartupLocation.CenterOwner;