Skip to content

Nasty bug when using OverrideDefaultWindowCommandsBrush #2086

@nikolovjovan

Description

@nikolovjovan

After messing around with custom MetroWindow and WindowCommands styles I found a bug that disables Foreground property change for every WindowCommands' buttons and therefore keeps me from applying my custom style. If I have a style defined like this:

<Style x:Key="CleanMetroWindowStyle"
       TargetType="{x:Type controls:MetroWindow}"
       BasedOn="{StaticResource {x:Type controls:MetroWindow}}">
    <Setter Property="OverrideDefaultWindowCommandsBrush"
            Value="{DynamicResource BlackBrush}" />
    <Setter Property="TitleForeground"
            Value="{DynamicResource BlackBrush}" />
    <Setter Property="WindowTitleBrush"
            Value="{DynamicResource TransparentWhiteBrush}" />
    <Setter Property="NonActiveWindowTitleBrush"
            Value="{DynamicResource TransparentWhiteBrush}" />
    <Setter Property="WindowMinButtonStyle"
            Value="{DynamicResource CleanMetroWindowButtonStyle}" />
    <Setter Property="WindowMaxButtonStyle"
            Value="{DynamicResource CleanMetroWindowButtonStyle}" />
    <Setter Property="WindowCloseButtonStyle"
            Value="{DynamicResource CustomCloseWindowButtonStyle}" />
</Style>

And when I change Foreground property of WindowCommands' buttons like this:

<controls:MetroWindow.RightWindowCommands>
    <controls:WindowCommands Foreground="Red">
        <Button Content="Button 1"
                Foreground="Red" />
        <Button Content="Button 2"
                Foreground="Red" />
    </controls:WindowCommands>
</controls:MetroWindow.RightWindowCommands>

nothing changes and the buttons stay black. If I remove that setter, everything works as expected. So as a workaround I set the color manually in all of my custom styles.
I hope this can be fixed since it's a nice solution to simply change the color but for now it doesn't allow any further modifications to be made.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions