Skip to content

Commit 3548094

Browse files
authored
Fix: Fixed issue where custom theme was not applied on launch (#10587)
Reload resources when applying theme
1 parent 4385fae commit 3548094

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/Files.App/Helpers/ExternalResourcesHelper.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public async Task<bool> TryLoadThemeAsync(AppTheme theme)
9797
{
9898
Themes.Add(theme);
9999
}
100+
ForceReloadResourceFile();
100101
return true;
101102
}
102103
return false;
@@ -108,6 +109,22 @@ public async Task<bool> TryLoadThemeAsync(AppTheme theme)
108109
}
109110
}
110111

112+
/// <summary>
113+
/// Forces the application to use the correct resource styles
114+
/// </summary>
115+
private void ForceReloadResourceFile()
116+
{
117+
// Get the index of the current theme
118+
var selTheme = ThemeHelper.RootTheme;
119+
120+
// Toggle between the themes to force the controls to use the new resource styles
121+
ThemeHelper.RootTheme = ElementTheme.Dark;
122+
ThemeHelper.RootTheme = ElementTheme.Light;
123+
124+
// Restore the theme to the correct theme
125+
ThemeHelper.RootTheme = selTheme;
126+
}
127+
111128
public async Task<ResourceDictionary> TryLoadResourceDictionary(AppTheme theme)
112129
{
113130
StorageFile file;

0 commit comments

Comments
 (0)