I tried all the other solutions found on this site or on others but it doesn't work. Here is button:
<Button Grid.Row="1" Grid.Column="0" HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" Margin="10,10,5,10" BorderThickness="3">
<Button.Background>
<SolidColorBrush Opacity="0.0" Color="#b3b3b3"/>
</Button.Background>
<Button.BorderBrush>
<SolidColorBrush Opacity="0.3" Color="Gray"/>
</Button.BorderBrush>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="5*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
</Grid>
</Button>
What I tried:
Addig a style in the Windows.Resources
:
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Gray"/>
</Trigger>
</Style.Triggers>
And adding this inside the button as well.
The two solutions I got was either nothing, the old highlighted look, or an error that I can't change the Content
twice. As I'm out of ideas, could someone show me how to change my button's highlighted look?
EDIT:
copied character by character from the thread I mentioned in my answer:
<Button Content="Button" HorizontalAlignment="Left" VerticalAlignment="Bottom" Width="50" Height="50" HorizontalContentAlignment="Left" BorderBrush="{x:Null}" Foreground="{x:Null}" Margin="50,0,0,0">
<Button.Style>
<Style TargetType="{x:Type Button}">
<Setter Property="Background" Value="Green"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="DarkGoldenrod"/>
</Trigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
Now it works. The reason it didn't was that my own button - in this question - had some of its own properties, like those brushes
and the grid
.