Avoid duplicated ResourceDictionary

This commit is contained in:
cuiliang committed 2021-08-11 14:38:45 +08:00
1 parent d7b4041ef5
commit d693312338
1 file changed
+13 -1
@@ -79,12 +79,24 @@ namespace HandyControl.Tools
Source = new Uri($"pack://application:,,,/HandyControl;component/Themes/Skin{skin}.xaml") Source = new Uri($"pack://application:,,,/HandyControl;component/Themes/Skin{skin}.xaml")
}; };
private static ResourceDictionary _theme;
/// <summary> /// <summary>
/// get HandyControl theme /// get HandyControl theme
/// </summary> /// </summary>
public static ResourceDictionary GetTheme() => new() public static ResourceDictionary GetTheme()
{
if (_theme == null)
{
_theme = new()
{ {
Source = new Uri("pack://application:,,,/HandyControl;component/Themes/Theme.xaml") Source = new Uri("pack://application:,,,/HandyControl;component/Themes/Theme.xaml")
}; };
} }
return _theme;
}
}
} }