@@ -18,7 +18,7 @@ internal static void OnSystemThemeChanged()
18
18
{
19
19
if ( IsFluentThemeEnabled )
20
20
{
21
- IgnoreAppResourcesChange = true ;
21
+ SkipAppThemeModeSyncing = true ;
22
22
23
23
try
24
24
{
@@ -51,7 +51,7 @@ internal static void OnSystemThemeChanged()
51
51
}
52
52
finally
53
53
{
54
- IgnoreAppResourcesChange = false ;
54
+ SkipAppThemeModeSyncing = false ;
55
55
}
56
56
57
57
}
@@ -76,7 +76,7 @@ internal static void OnSystemThemeChanged()
76
76
77
77
internal static void OnApplicationThemeChanged ( ThemeMode oldThemeMode , ThemeMode newThemeMode )
78
78
{
79
- IgnoreAppResourcesChange = true ;
79
+ SkipAppThemeModeSyncing = true ;
80
80
81
81
try
82
82
{
@@ -107,7 +107,7 @@ internal static void OnApplicationThemeChanged(ThemeMode oldThemeMode, ThemeMode
107
107
}
108
108
finally
109
109
{
110
- IgnoreAppResourcesChange = false ;
110
+ SkipAppThemeModeSyncing = false ;
111
111
}
112
112
}
113
113
@@ -125,12 +125,9 @@ internal static void OnWindowThemeChanged(Window window, ThemeMode oldThemeMode,
125
125
ApplyFluentOnWindow ( window ) ;
126
126
}
127
127
128
- internal static bool SyncThemeModeAndResources ( )
128
+ internal static bool SyncThemeMode ( )
129
129
{
130
- if ( DeferSyncingThemeModeAndResources )
131
- return true ;
132
-
133
- ThemeMode themeMode = GetThemeModeFromResourceDictionary ( Application . Current . Resources ) ;
130
+ ThemeMode themeMode = GetThemeModeFromResourceDictionary ( Application . Current . Resources ) ;
134
131
135
132
if ( Application . Current . ThemeMode != themeMode )
136
133
{
@@ -140,9 +137,11 @@ internal static bool SyncThemeModeAndResources()
140
137
return false ;
141
138
}
142
139
143
- internal static void SyncDeferredThemeModeAndResources ( )
140
+ internal static void SyncThemeModeAndResources ( )
144
141
{
145
- if ( Application . Current == null )
142
+ // Since, this is called from window there is a possiblity that the application
143
+ // instance is null. Hence, we need to check for null.
144
+ if ( Application . Current == null )
146
145
return ;
147
146
148
147
ThemeMode themeMode = Application . Current . ThemeMode ;
@@ -317,7 +316,7 @@ private static void ApplyStyleOnWindow(Window window, bool useLightColors)
317
316
318
317
#region Internal Properties
319
318
320
- internal static bool DeferSyncingThemeModeAndResources { get ; set ; } = true ;
319
+ internal static bool IsAppThemeModeSyncEnabled { get ; set ; } = false ;
321
320
322
321
internal static bool IsFluentThemeEnabled
323
322
{
@@ -331,7 +330,7 @@ internal static bool IsFluentThemeEnabled
331
330
332
331
internal static bool DeferredAppThemeLoading { get ; set ; } = false ;
333
332
334
- internal static bool IgnoreAppResourcesChange { get ; set ; } = false ;
333
+ internal static bool SkipAppThemeModeSyncing { get ; set ; } = false ;
335
334
336
335
internal static double DefaultFluentThemeFontSize => 14 ;
337
336
0 commit comments