public static void ReplaceAllResources(ResourceDictionary dicts, string themeName, ResourceDictionary themeResource)
        {
            //for (int i = dicts.MergedDictionaries.Count - 1; i >= 0; i--)
            //{
            //    var rd = dicts.MergedDictionaries[i];
            var rdString = dicts.Source.OriginalString;

            //foreach (var rdInner in rd.MergedDictionaries)
            //{
            //    rdInner.ReplaceResourcesInDictionary(themeName, themeResource);
            //}
            if (rdString.Contains(themeName))
            {
                var keys   = themeResource.Keys as List <string>;
                var values = themeResource.Values as List <object>;


                var pairs = themeResource as IEnumerable <KeyValuePair <object, object> >;
                foreach (KeyValuePair <object, object> pair in pairs)
                {
                    dicts.FindAndReplaceAllResources(pair.Key as string, pair.Value);

                    var resource = pair.Value;
                    if (resource is Color)
                    {
                    }
                    //else if (pair.Value is SolidColorBrush)
                    //{
                    //    solidBrush = (SolidColorBrush)resource;
                    //}
                    //else if (pair.Value is LinearGradientBrush)
                    //{
                    //    linearBrush = (LinearGradientBrush)resource;
                    //}
                    //else if (pair.Value is RadialGradientBrush)
                    //{
                    //    radialBrush = (RadialGradientBrush)resource;
                    //}
                    //}
                }

                //dicts.MergedDictionaries.RemoveAt(i);
                //dicts.MergedDictionaries.Insert(i, themeResource);
            }
            // }
        }