Skip to content

Commit

Permalink
Fix issue where creating a modern window before ThemeManager is initi…
Browse files Browse the repository at this point in the history
…alized can crash the app
  • Loading branch information
Kinnara committed Nov 7, 2019
1 parent 7d89cdd commit 8e09156
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ModernWpf/ThemeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,12 @@ internal static void UpdateWindowActualTheme(Window window)
var requestedTheme = GetRequestedTheme(window);
if (requestedTheme == ElementTheme.Default)
{
SetActualTheme(window, Current.ActualApplicationTheme.Value == ModernWpf.ApplicationTheme.Dark ? ElementTheme.Dark : ElementTheme.Light);
var actualAppTheme = Current.ActualApplicationTheme;
if (actualAppTheme.HasValue)
{
SetActualTheme(window, actualAppTheme.Value == ModernWpf.ApplicationTheme.Dark ?
ElementTheme.Dark : ElementTheme.Light);
}
}
else
{
Expand Down

0 comments on commit 8e09156

Please sign in to comment.