
Hellow,
I'd like to cancel changing active window.
Would you please teach me how to do it? (I'm using DockSite with MVVM pattern)
I have tried to change "MVVM DocumentWindows" sample as the following.
However, it does not work properly.
<Change point of sample program>
- Add `CanDocumentWindowsFloat="True"` to dockSite in MainView.xaml.
- Add below override method in TextDocumentItemViewModel.cs.
protected override void OnPropertyChanged(PropertyChangedEventArgs e)
{
if (e.PropertyName == "IsActive" && Title == "Document1.txt")
{
if (!IsActive)
{
var choice = MessageBox.Show("Do you want to switch active window?", Title, MessageBoxButton.YesNo);
if (choice == MessageBoxResult.Yes)
{
base.OnPropertyChanged(e);
return;
}
Application.Current.Dispatcher.BeginInvoke(() =>
{
IsActive = true;
});
}
else
{
base.OnPropertyChanged(e);
}
}
else
{
base.OnPropertyChanged(e);
}
}
}
<Result>
- When I change active window to Document2.txt from Document1.txt and select "Yes" on messagebox, messagebox is shown again and window of Document2.txt is displayed as floating.
Best regards,
[Modified 2 years ago]