From a1aa721e2f91e7d0cee0de7db0cfe8971d89f133 Mon Sep 17 00:00:00 2001 From: eriove Date: Thu, 1 Apr 2021 13:32:14 +0200 Subject: [PATCH 1/2] Fixing problems with tests running with XUnit StaFact --- source/Components/AvalonDock/DockingManager.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/Components/AvalonDock/DockingManager.cs b/source/Components/AvalonDock/DockingManager.cs index 1c68e2c4..bac38d0d 100644 --- a/source/Components/AvalonDock/DockingManager.cs +++ b/source/Components/AvalonDock/DockingManager.cs @@ -1882,7 +1882,9 @@ protected override void OnPreviewKeyDown(KeyEventArgs e) /// private static void OnContextMenuPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { - if (e.NewValue is ContextMenu contextMenu) + if (d.Dispatcher.CheckAccess() && + e.NewValue is ContextMenu contextMenu && + contextMenu.Dispatcher.CheckAccess()) { contextMenu.Resources = ((DockingManager)d).Resources; } From c3729ab056798f19b247b6534946e61541f452c6 Mon Sep 17 00:00:00 2001 From: eriove Date: Mon, 12 Apr 2021 12:37:23 +0200 Subject: [PATCH 2/2] Alternative fix --- source/Components/AvalonDock/DockingManager.cs | 4 +--- source/Components/AvalonDock/Themes/generic.xaml | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/source/Components/AvalonDock/DockingManager.cs b/source/Components/AvalonDock/DockingManager.cs index bac38d0d..1c68e2c4 100644 --- a/source/Components/AvalonDock/DockingManager.cs +++ b/source/Components/AvalonDock/DockingManager.cs @@ -1882,9 +1882,7 @@ protected override void OnPreviewKeyDown(KeyEventArgs e) /// private static void OnContextMenuPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { - if (d.Dispatcher.CheckAccess() && - e.NewValue is ContextMenu contextMenu && - contextMenu.Dispatcher.CheckAccess()) + if (e.NewValue is ContextMenu contextMenu) { contextMenu.Resources = ((DockingManager)d).Resources; } diff --git a/source/Components/AvalonDock/Themes/generic.xaml b/source/Components/AvalonDock/Themes/generic.xaml index b958e806..f3bfad2d 100644 --- a/source/Components/AvalonDock/Themes/generic.xaml +++ b/source/Components/AvalonDock/Themes/generic.xaml @@ -662,8 +662,8 @@ - - + +