From b72af9e65138d29385a3c301b926b07f442fbc34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Karger=20=E3=83=84=20=E2=98=80?= Date: Tue, 20 Apr 2021 12:52:35 +0200 Subject: [PATCH 1/3] Merge pull request #4088 from MahApps/fix/GH-4065 Fix issue #4065 --- src/MahApps.Metro/Themes/DateTimePicker.xaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MahApps.Metro/Themes/DateTimePicker.xaml b/src/MahApps.Metro/Themes/DateTimePicker.xaml index 8c86d0542d..983720d3ed 100644 --- a/src/MahApps.Metro/Themes/DateTimePicker.xaml +++ b/src/MahApps.Metro/Themes/DateTimePicker.xaml @@ -474,10 +474,10 @@ - + - + From 11a5fa5d85d73b65d4a3c78b75bb269445eb42e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Karger=20=E3=83=84=20=E2=98=80?= Date: Tue, 20 Apr 2021 16:35:18 +0200 Subject: [PATCH 2/3] Merge pull request #4076 from Jan18101997/develop Fixed issue #4072 --- .../Behaviors/WindowsSettingBehavior.cs | 18 ++++++++---------- src/MahApps.Metro/Controls/Extensions.cs | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/MahApps.Metro/Behaviors/WindowsSettingBehavior.cs b/src/MahApps.Metro/Behaviors/WindowsSettingBehavior.cs index d144e11e6d..c9bf1edb1a 100644 --- a/src/MahApps.Metro/Behaviors/WindowsSettingBehavior.cs +++ b/src/MahApps.Metro/Behaviors/WindowsSettingBehavior.cs @@ -46,15 +46,14 @@ private void AssociatedObject_SourceInitialized(object sender, EventArgs e) window.Closing += this.AssociatedObject_Closing; window.Closed += this.AssociatedObject_Closed; - // This operation must be thread safe - window.BeginInvoke(() => + // This operation must be thread safe. It is possible, that the window is running in a different Thread. + Application.Current?.BeginInvoke(app => { - var application = Application.Current; - if (application != null) + if (app != null) { - application.SessionEnding += this.CurrentApplicationSessionEnding; + app.SessionEnding += this.CurrentApplicationSessionEnding; } - }); + }); } private void AssociatedObject_Closing(object sender, System.ComponentModel.CancelEventArgs e) @@ -100,12 +99,11 @@ private void CleanUp(string fromWhere) window.SourceInitialized -= this.AssociatedObject_SourceInitialized; // This operation must be thread safe - window.BeginInvoke(() => + Application.Current?.BeginInvoke(app => { - var application = Application.Current; - if (application != null) + if (app != null) { - application.SessionEnding -= this.CurrentApplicationSessionEnding; + app.SessionEnding -= this.CurrentApplicationSessionEnding; } }); } diff --git a/src/MahApps.Metro/Controls/Extensions.cs b/src/MahApps.Metro/Controls/Extensions.cs index c90df105ba..534bc1ee65 100644 --- a/src/MahApps.Metro/Controls/Extensions.cs +++ b/src/MahApps.Metro/Controls/Extensions.cs @@ -73,7 +73,7 @@ public static void BeginInvoke([NotNull] this DispatcherObject dispatcherObject, throw new ArgumentNullException(nameof(invokeAction)); } - dispatcherObject.Dispatcher.BeginInvoke(priority, invokeAction); + dispatcherObject.Dispatcher?.BeginInvoke(priority, invokeAction); } public static void BeginInvoke([NotNull] this T dispatcherObject, [NotNull] Action invokeAction, DispatcherPriority priority = DispatcherPriority.Background) From 135c2d876d91992ae492607d789d3c47c77ab1b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Karger=20=E3=83=84=20=E2=98=80?= Date: Tue, 20 Apr 2021 16:49:48 +0200 Subject: [PATCH 3/3] Merge pull request #4087 from pastukh0v/Fixing_issue_4083 Fix bug #4083 --- src/MahApps.Metro/Themes/DateTimePicker.xaml | 1 - 1 file changed, 1 deletion(-) diff --git a/src/MahApps.Metro/Themes/DateTimePicker.xaml b/src/MahApps.Metro/Themes/DateTimePicker.xaml index 983720d3ed..1e630079fe 100644 --- a/src/MahApps.Metro/Themes/DateTimePicker.xaml +++ b/src/MahApps.Metro/Themes/DateTimePicker.xaml @@ -441,7 +441,6 @@ -