0

As the title says, I simply can't get the trigger to change the background working inside the template. I'm stuck now for a couple days...

My template:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Style TargetType="{x:Type Button}"
           x:Key="TitleBarButtonTheme">
        <Style.Setters>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Grid VerticalAlignment="Stretch "
                              HorizontalAlignment="Stretch"
                              >
                            <TextBlock Text="{TemplateBinding Property=Content}"
                                       VerticalAlignment="Center"
                                       HorizontalAlignment="Center"
                                       Foreground="#adadad"
                                       Width="{TemplateBinding Property=Width}"
                                       Height="{TemplateBinding Property=Height}"/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style.Setters>
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="Red"/>
            </Trigger>
        </Style.Triggers>
    </Style>
</ResourceDictionary>

the view:

<Button Width="21" Height="16"
        Content="_"
        Style="{StaticResource TitleBarButtonTheme}"/>
Ogie
  • 3
  • 3

1 Answers1

0

Insert Background property

<ControlTemplate TargetType="{x:Type Button}">
    <Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Background="{TemplateBinding Background}">
.
.
.
</ControlTemplate >
Heal Song
  • 30
  • 4