当前位置: 首页>>代码示例>>C#>>正文


C# ResourceDictionary.BeginInit方法代码示例

本文整理汇总了C#中System.Windows.ResourceDictionary.BeginInit方法的典型用法代码示例。如果您正苦于以下问题:C# ResourceDictionary.BeginInit方法的具体用法?C# ResourceDictionary.BeginInit怎么用?C# ResourceDictionary.BeginInit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.ResourceDictionary的用法示例。


在下文中一共展示了ResourceDictionary.BeginInit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
		}
开发者ID:cssack,项目名称:CsGlobals,代码行数:8,代码来源:Resource.Dictionary.cs

示例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();
        }
开发者ID:pdsullivan,项目名称:MahApps.Metro,代码行数:14,代码来源:ThemeManager.cs

示例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();
        }
开发者ID:daszat,项目名称:zetbox,代码行数:34,代码来源:App.cs

示例4: SetCurrent

        /// <summary>
        /// Set the current theme
        /// </summary>
        /// <param name="name">The name of the theme</param>
        /// <returns>true if the new theme is set, false otherwise</returns>
        public bool SetCurrent(string name)
        {
            if (ThemeDictionary.ContainsKey(name))
            {
                ITheme newTheme = ThemeDictionary[name];
                CurrentTheme = newTheme;

                ResourceDictionary theme = Application.Current.MainWindow.Resources.MergedDictionaries[0];
                ResourceDictionary appTheme = Application.Current.Resources.MergedDictionaries.Count > 0
                                                  ? Application.Current.Resources.MergedDictionaries[0]
                                                  : null;
                theme.BeginInit();
                theme.MergedDictionaries.Clear();
                if (appTheme != null)
                {
                    appTheme.BeginInit();
                    appTheme.MergedDictionaries.Clear();
                }
                else
                {
                    appTheme = new ResourceDictionary();
                    appTheme.BeginInit();
                    Application.Current.Resources.MergedDictionaries.Add(appTheme);
                }
                foreach (Uri uri in newTheme.UriList)
                {
                    ResourceDictionary newDict = new ResourceDictionary {Source = uri};
                    /*AvalonDock and menu style needs to move to the application
                     * 1. AvalonDock needs global styles as floatable windows can be created
                     * 2. Menu's need global style as context menu can be created
                    */
                    if (uri.ToString().Contains("AvalonDock") ||
                        uri.ToString().Contains("Wide;component/Interfaces/Styles/VS2012/Menu.xaml"))
                    {
                        appTheme.MergedDictionaries.Add(newDict);
                    }
                    else
                    {
                        theme.MergedDictionaries.Add(newDict);
                    }
                }
                appTheme.EndInit();
                theme.EndInit();
                _logger.Log("Theme set to " + name, LogCategory.Info, LogPriority.None);
                _eventAggregator.GetEvent<ThemeChangeEvent>().Publish(newTheme);
            }
            return false;
        }
开发者ID:ruisebastiao,项目名称:Wide,代码行数:53,代码来源:ThemeManager.cs


注:本文中的System.Windows.ResourceDictionary.BeginInit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。