本文整理汇总了C#中System.Windows.ResourceDictionary.EndInit方法的典型用法代码示例。如果您正苦于以下问题:C# ResourceDictionary.EndInit方法的具体用法?C# ResourceDictionary.EndInit怎么用?C# ResourceDictionary.EndInit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.ResourceDictionary
的用法示例。
在下文中一共展示了ResourceDictionary.EndInit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
private static ResourceDictionary Load(string filepath)
{
var dict = new ResourceDictionary();
dict.BeginInit();
dict.Source = new Uri(filepath, UriKind.RelativeOrAbsolute);
dict.EndInit();
return dict;
}
示例2: ApplyResourceDictionary
private static void ApplyResourceDictionary(ResourceDictionary newRd, ResourceDictionary oldRd)
{
oldRd.BeginInit();
foreach (DictionaryEntry r in newRd)
{
if (oldRd.Contains(r.Key))
oldRd.Remove(r.Key);
oldRd.Add(r.Key, r.Value);
}
oldRd.EndInit();
}
示例3: LoadStyles
private void LoadStyles(ResourceDictionary targetResources)
{
targetResources.BeginInit();
// Basic resources
targetResources.MergedDictionaries.Add(Freeze(new ResourceDictionary() { Source = new Uri("/Zetbox.Client.WPF;component/AppResources.xaml", UriKind.Relative) }));
// Init all Converter that need a constructor
var templateSelectorFactory = container.Resolve<Zetbox.Client.WPF.Toolkit.VisualTypeTemplateSelector.Factory>();
targetResources["defaultTemplateSelector"] = templateSelectorFactory(null);
targetResources["listItemTemplateSelector"] = templateSelectorFactory("Zetbox.App.GUI.SingleLineKind");
targetResources["dashBoardTemplateSelector"] = templateSelectorFactory("Zetbox.App.GUI.DashboardKind");
// Manually add DefaultStyles and DefaultViews to enable override through Autofac
targetResources.MergedDictionaries.Add(Freeze(new ResourceDictionary() { Source = new Uri("/Zetbox.Client.WPF;component/Styles/DefaultStyles.xaml", UriKind.Relative) }));
targetResources.MergedDictionaries.Add(Freeze(new ResourceDictionary() { Source = new Uri("/Zetbox.Client.WPF;component/Styles/DefaultHighlightColorDefinitions.xaml", UriKind.Relative) }));
// Load registrated dictionaries from autofac
foreach (var dict in container.Resolve<IEnumerable<Meta<ResourceDictionary>>>().Where(m => WPFHelper.RESOURCE_DICTIONARY_STYLE.Equals(m.Metadata[WPFHelper.RESOURCE_DICTIONARY_KIND])).Select(m => m.Value))
{
targetResources.MergedDictionaries.Add(Freeze(dict));
}
// For testing only!!!!
// targetResources.MergedDictionaries.Add(Freeze(new ResourceDictionary() { Source = new Uri("/Zetbox.Client.WPF;component/Styles/BigFontStyles.xaml", UriKind.Relative) }));
targetResources.MergedDictionaries.Add(Freeze(new ResourceDictionary() { Source = new Uri("/Zetbox.Client.WPF;component/Styles/DefaultViews.xaml", UriKind.Relative) }));
targetResources.MergedDictionaries.Add(Freeze(new ResourceDictionary() { Source = new Uri("/Zetbox.Client.WPF;component/Styles/CustomControls.xaml", UriKind.Relative) }));
// Load registrated dictionaries from autofac
foreach (var dict in container.Resolve<IEnumerable<Meta<ResourceDictionary>>>().Where(m => WPFHelper.RESOURCE_DICTIONARY_VIEW.Equals(m.Metadata[WPFHelper.RESOURCE_DICTIONARY_KIND])).Select(m => m.Value))
{
targetResources.MergedDictionaries.Add(Freeze(dict));
}
targetResources.EndInit();
}