Skip to content

Commit d693312

Browse files
committed
Avoid duplicated ResourceDictionary
1 parent d7b4041 commit d693312

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/Shared/HandyControl_Shared/Tools/Helper/ResourceHelper.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,24 @@ public static ResourceDictionary GetSkin(Assembly assembly, string themePath, Sk
7979
Source = new Uri($"pack://application:,,,/HandyControl;component/Themes/Skin{skin}.xaml")
8080
};
8181

82+
83+
84+
private static ResourceDictionary _theme;
85+
8286
/// <summary>
8387
/// get HandyControl theme
8488
/// </summary>
85-
public static ResourceDictionary GetTheme() => new()
89+
public static ResourceDictionary GetTheme()
8690
{
87-
Source = new Uri("pack://application:,,,/HandyControl;component/Themes/Theme.xaml")
88-
};
91+
if (_theme == null)
92+
{
93+
_theme = new()
94+
{
95+
Source = new Uri("pack://application:,,,/HandyControl;component/Themes/Theme.xaml")
96+
};
97+
}
98+
99+
return _theme;
100+
}
89101
}
90102
}

0 commit comments

Comments
 (0)