hello,
After close dialog thougth close button, sometimes it reopens inexplicably.
Dialog is open thougth message. It is reopened when the message is sent, however, only once.
public partial class AssociationDialog : Window { public AssociationDialog() { InitializeComponent(); } private void Button_Click(object sender, RoutedEventArgs e) { this.DialogResult = true; this.Close(); } }
Messenger.Default.Register<NotificationMessage>(this, message => { if (message.Notification == Notifications.AssociationDialog) { var window = new AssociationDialog(); window.DataContext = new AssociationDialogViewModel(); window.ShowDialog(); if (window.DialogResult.HasValue && window.DialogResult.Value) { AssociationDialogViewModel vm = window.DataContext as AssociationDialogViewModel; Messenger.Default.Send(new NotificationMessage<DictionaryEntry>(new DictionaryEntry(vm.Key, vm.Value), Notifications.AddAssociation)); } } });