Skip to content

Commit 4025dca

Browse files
committed
Merge branch 'hotfix/2.4.5' into main
2 parents 29a0ac4 + 135c2d8 commit 4025dca

3 files changed

Lines changed: 11 additions & 14 deletions

File tree

src/MahApps.Metro/Behaviors/WindowsSettingBehavior.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,14 @@ private void AssociatedObject_SourceInitialized(object sender, EventArgs e)
4646
window.Closing += this.AssociatedObject_Closing;
4747
window.Closed += this.AssociatedObject_Closed;
4848

49-
// This operation must be thread safe
50-
window.BeginInvoke(() =>
49+
// This operation must be thread safe. It is possible, that the window is running in a different Thread.
50+
Application.Current?.BeginInvoke(app =>
5151
{
52-
var application = Application.Current;
53-
if (application != null)
52+
if (app != null)
5453
{
55-
application.SessionEnding += this.CurrentApplicationSessionEnding;
54+
app.SessionEnding += this.CurrentApplicationSessionEnding;
5655
}
57-
});
56+
});
5857
}
5958

6059
private void AssociatedObject_Closing(object sender, System.ComponentModel.CancelEventArgs e)
@@ -100,12 +99,11 @@ private void CleanUp(string fromWhere)
10099
window.SourceInitialized -= this.AssociatedObject_SourceInitialized;
101100

102101
// This operation must be thread safe
103-
window.BeginInvoke(() =>
102+
Application.Current?.BeginInvoke(app =>
104103
{
105-
var application = Application.Current;
106-
if (application != null)
104+
if (app != null)
107105
{
108-
application.SessionEnding -= this.CurrentApplicationSessionEnding;
106+
app.SessionEnding -= this.CurrentApplicationSessionEnding;
109107
}
110108
});
111109
}

src/MahApps.Metro/Controls/Extensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public static void BeginInvoke([NotNull] this DispatcherObject dispatcherObject,
7373
throw new ArgumentNullException(nameof(invokeAction));
7474
}
7575

76-
dispatcherObject.Dispatcher.BeginInvoke(priority, invokeAction);
76+
dispatcherObject.Dispatcher?.BeginInvoke(priority, invokeAction);
7777
}
7878

7979
public static void BeginInvoke<T>([NotNull] this T dispatcherObject, [NotNull] Action<T> invokeAction, DispatcherPriority priority = DispatcherPriority.Background)

src/MahApps.Metro/Themes/DateTimePicker.xaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,6 @@
441441

442442
<Trigger Property="IsClockVisible" Value="False">
443443
<Setter TargetName="PART_Clock" Property="Visibility" Value="Collapsed" />
444-
<Setter TargetName="PART_ClockPartSelectorsHolder" Property="Visibility" Value="Collapsed" />
445444
</Trigger>
446445
<Trigger Property="IsDatePickerVisible" Value="True">
447446
<Setter TargetName="PART_Calendar" Property="Visibility" Value="Visible" />
@@ -474,10 +473,10 @@
474473
<Condition Binding="{Binding Path=(mah:TextBoxHelper.HasText), RelativeSource={RelativeSource Self}}" Value="True" />
475474
</MultiDataTrigger.Conditions>
476475
<MultiDataTrigger.EnterActions>
477-
<BeginStoryboard Storyboard="{DynamicResource MahApps.Storyboard.ShowFloatingMessage}" />
476+
<BeginStoryboard Storyboard="{StaticResource MahApps.Storyboard.ShowFloatingMessage}" />
478477
</MultiDataTrigger.EnterActions>
479478
<MultiDataTrigger.ExitActions>
480-
<BeginStoryboard Storyboard="{DynamicResource MahApps.Storyboard.HideFloatingMessage}" />
479+
<BeginStoryboard Storyboard="{StaticResource MahApps.Storyboard.HideFloatingMessage}" />
481480
</MultiDataTrigger.ExitActions>
482481
</MultiDataTrigger>
483482

0 commit comments

Comments
 (0)