Ejemplo n.º 1
0
        internal void Update(string themeKey)
        {
            if (ThemeDictionaries.TryGetValue(themeKey, out ResourceDictionary themeDictionary))
            {
                if (_mergedThemeDictionary != null)
                {
                    if (_mergedThemeDictionary == themeDictionary)
                    {
                        return;
                    }
                    else
                    {
                        int targetIndex = MergedDictionaries.IndexOf(_mergedThemeDictionary);
                        MergedDictionaries[targetIndex] = themeDictionary;
                        _mergedThemeDictionary          = themeDictionary;
                    }
                }
                else
                {
                    int targetIndex;

                    if (MergedAppThemeDictionary != null)
                    {
                        targetIndex = MergedDictionaries.IndexOf(MergedAppThemeDictionary) + 1;
                    }
                    else
                    {
                        targetIndex = 0;
                    }

                    MergedDictionaries.Insert(targetIndex, themeDictionary);
                    _mergedThemeDictionary = themeDictionary;
                }
            }
            else
            {
                if (_mergedThemeDictionary != null)
                {
                    MergedDictionaries.Remove(_mergedThemeDictionary);
                    _mergedThemeDictionary = null;
                }
            }
        }