Why does my button work only when I click on either the text inside or the picture?
<ControlTemplate TargetType="{x:Type Button}" x:Key="FlatButton"> ........ <Button Template="{StaticResource FlatButton}" Margin="0,0,0,448" BorderThickness="1" Background="{x:Null}" BorderBrush="{x:Null}" Foreground="{x:Null}"> <StackPanel Orientation="Horizontal" Margin="0"> <Image Source="icon/add-new-document.png" Width="30" Margin="20,0,0,0" /> <TextBlock Text="Создать новый документ" Foreground="White" VerticalAlignment="Center" Margin="16,0,0,0" FontSize="14" FontWeight="Bold"/> <StackPanel.Style> <Style TargetType="StackPanel"> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Background" Value="#FF002354" /> </Trigger> </Style.Triggers> </Style> </StackPanel.Style> </StackPanel> </Button> And yet, is it possible to stuff all this in style, so that for each button you don’t write the same thing?
UPD 1
No way: (does not want to be installed ...
<ControlTemplate TargetType="{x:Type Button}" x:Key="FlatButton"> <Setter Property="Background" Value="Transparent"/> <ContentPresenter/> </ControlTemplate> UPD 2
<Button Template="{StaticResource FlatButton}" Margin="0,0,0,448" BorderThickness="1"> <StackPanel Orientation="Horizontal" Margin="0" Background="Transparent"> <Image Source="icon/add-new-document.png" Width="30" Margin="20,0,0,0" /> <TextBlock Text="Создать новый документ" Foreground="White" VerticalAlignment="Center" Margin="16,0,0,0" FontSize="14" FontWeight="Bold"/> <StackPanel.Style> <Style TargetType="StackPanel"> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Background" Value="#FF002354" /> </Trigger> </Style.Triggers> </Style> </StackPanel.Style> </StackPanel> </Button> 

StackPaneltoBackground="Transparent". - VladD<Setter Property="Background" Value="Transparent"/>. The trigger is triggered, just the background directly installed is stronger than the background from the style. - VladD