public static void CreateAccentColorResourceDictionary(this Color color, string controlName)
        {
            var accentColor = Application.Current.TryFindResource(controlName.GetAccentBrushName()) as SolidColorBrush;

            if (accentColor != null)
            {
                return;
            }

            if (_accentColorResourceDictionary != null)
            {
                _accentColorResourceDictionary.AddResources(color, controlName);
            }

            var resourceDictionary = new ResourceDictionary();

            resourceDictionary.AddResources(color, controlName);

            var application          = Application.Current;
            var applicationResources = application.Resources;

            applicationResources.MergedDictionaries.Insert(0, resourceDictionary);

            _accentColorResourceDictionary = resourceDictionary;
        }
Exemple #2
0
        /// <summary>
        /// 创建主色
        /// </summary>
        public static void CreateAccentColors(this Color color)
        {
            ResourceDictionary dictionary = Application.Current.Resources;

            if (!dictionary.Contains(color.ToString()))
            {
                var resources = new ResourceDictionary();
                resources.AddResources(color);
                dictionary.MergedDictionaries.Insert(0, resources);
                dictionary.Add(color.ToString(), color);
            }
        }
Exemple #3
0
        public static void CreateAccentColors(this Color color)
        {
            var accentColor = Application.Current.TryFindResource(AccentBrush) as SolidColorBrush;

            if (accentColor != null)
            {
                return;
            }

            if (_accentResources != null)
            {
                _accentResources.AddResources(color);
            }

            var resources = new ResourceDictionary();

            resources.AddResources(color);
            var application          = Application.Current;
            var applicationResources = application.Resources;

            applicationResources.MergedDictionaries.Insert(0, resources);
            _accentResources = resources;
        }