Improve the performance of merged ResourceDictionaries
This commit is contained in:
1 parent
2a89bf42f7
commit
39b1296727
144 files changed
+679
-503
No files matched your search
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using HandyControl.Tools;
|
||||
|
||||
namespace HandyControl.Themes
|
||||
{
|
||||
public class SharedResourceDictionary : ResourceDictionary
|
||||
{
|
||||
public static Dictionary<Uri, ResourceDictionary> SharedDictionaries = new Dictionary<Uri, ResourceDictionary>();
|
||||
|
||||
private Uri _sourceUri;
|
||||
|
||||
public new Uri Source
|
||||
{
|
||||
get => DesignerHelper.IsInDesignMode ? base.Source : _sourceUri;
|
||||
set
|
||||
{
|
||||
if (value == null) return;
|
||||
if (DesignerHelper.IsInDesignMode)
|
||||
{
|
||||
base.Source = value;
|
||||
return;
|
||||
}
|
||||
_sourceUri = value;
|
||||
|
||||
if (!SharedDictionaries.ContainsKey(value))
|
||||
{
|
||||
base.Source = value;
|
||||
SharedDictionaries.Add(value, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
MergedDictionaries.Add(SharedDictionaries[value]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user