MaterialDesignInXAML / MaterialDesignInXamlToolkit

Google's Material Design in XAML & WPF, for C# & VB.Net.
http://materialdesigninxaml.net
MIT License
15.02k stars 3.41k forks source link

Dragablz tab selection highlight is gone (in at least 4.1.0 release) #2349

Closed bebenins closed 3 years ago

bebenins commented 3 years ago

Demo app image

My app (new vs old) image

My previous DLLs are year old so I can't tell where it broke.

Keboo commented 3 years ago

This was broken by the breaking change in #2080 [Dragablz is making the assumption that SecondaryAccentBrush will be defined] (https://github.com/ButchersBoy/Dragablz/blob/da7a4e58e1986b59fade3805f3777e6acb3e8fc5/Dragablz/Themes/MaterialDesign.xaml#L152) but this brush was renamed to SecondaryHueMidBrush.

I checked in a sample to the Dragablz demo app to show how to work around the issue since I suspect there will be other occurrences with changing brush names where this example will help people.

The code looks like this in your App.xaml.cs

public partial class App : Application
{
    protected override void OnStartup(StartupEventArgs e)
    {
        base.OnStartup(e);

        //Add/Update brush used by Dragablz when the theme changes
        //Solution for https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/issues/2349
        PaletteHelper helper = new PaletteHelper();
        if (helper.GetThemeManager() is { } themeManager)
        {
            themeManager.ThemeChanged += ThemeManager_ThemeChanged;
        }
    }

    private void ThemeManager_ThemeChanged(object? sender, ThemeChangedEventArgs e)
    {
        Resources["SecondaryAccentBrush"] = new SolidColorBrush(e.NewTheme.SecondaryMid.Color);
    }
}