Answer the question
In order to leave comments, you need to log in
Trigger for color change
There are 2 buttons
<Button Content="Какая-то кнопка" Style="{StaticResource LineButton}"/>
<Button Content="Button" Grid.Row="1" Style="{StaticResource LineButton}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<DockPanel LastChildFill="True">
<Grid x:Name="controlLayout">
<Rectangle x:Name="buttonSurface"
Fill="{TemplateBinding Background}"/>
<Label x:Name="buttonCaption"
Content="{TemplateBinding Content}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="{TemplateBinding Background}"/>
</Grid>
</DockPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="buttonCaption"
Property="Background" Value="#FFFFF500"/>
<Setter TargetName="buttonSurface"
Property="Fill" Value="#FFFFF500"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
Answer the question
In order to leave comments, you need to log in
If options with multiple styles are not suitable, then inherit from the button and create a DependencyProperty to which you will bind from the style.
I think that the easiest way, in order not to change the existing code, is to make all changes directly in the code (C #) - for example, in the OnApplyTemplate method or in any other initializer, explicitly indicate which button should have which color. those. create some method SetButtonOnMouseOberTriggerColor in which, go through this pattern from the code...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question