Exemple #1
0
        internal void ChangeFlyoutTheme(MahApps.Metro.Theme windowTheme)
        {
            // Beware: Über-dumb code ahead!
            switch (this.Theme)
            {
            case FlyoutTheme.Accent:
                ThemeManager.ApplyThemeResourcesFromTheme(this.Resources, windowTheme);
                this.OverrideFlyoutResources(this.Resources, true);
                break;

            case FlyoutTheme.Adapt:
                ThemeManager.ApplyThemeResourcesFromTheme(this.Resources, windowTheme);
                this.OverrideFlyoutResources(this.Resources);
                break;

            case FlyoutTheme.Inverse:
                var inverseTheme = ThemeManager.GetInverseTheme(windowTheme);

                if (inverseTheme == null)
                {
                    throw new InvalidOperationException("The inverse flyout theme only works if the window theme abides the naming convention. " +
                                                        "See ThemeManager.GetInverseAppTheme for more infos");
                }

                ThemeManager.ApplyThemeResourcesFromTheme(this.Resources, inverseTheme);
                this.OverrideFlyoutResources(this.Resources);
                break;

            case FlyoutTheme.Dark:
                ThemeManager.ApplyThemeResourcesFromTheme(this.Resources, ThemeManager.Themes.First(x => x.BaseColorScheme == ThemeManager.BaseColorDark && x.ColorScheme == windowTheme.ColorScheme));
                this.OverrideFlyoutResources(this.Resources);
                break;

            case FlyoutTheme.Light:
                ThemeManager.ApplyThemeResourcesFromTheme(this.Resources, ThemeManager.Themes.First(x => x.BaseColorScheme == ThemeManager.BaseColorLight && x.ColorScheme == windowTheme.ColorScheme));
                this.OverrideFlyoutResources(this.Resources);
                break;
            }
        }