Trying to change the standard button selection.
ControlTemplate ct = new ControlTemplate(); var t = new Trigger(); ct.Triggers = t.Property
I know that Property needs to be changed, but I don’t know what to write next Anyone tell me?
You can define a style in App.xaml
and get it using
MyButton.Style = FindResource("MyButtonStyle") as Style;
An example of a style to change the default button selection
<Application.Resources> <Style x:Key="MyButtonStyle" TargetType="{x:Type Button}"> <Setter Property="Background" Value="LightGreen"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/> </Border> </ControlTemplate> </Setter.Value> </Setter> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Background" Value="Orange"/> </Trigger> <Trigger Property="IsPressed" Value="True"> <Setter Property="Background" Value="LightSkyBlue"/> </Trigger> </Style.Triggers> </Style> </Application.Resources>
Here you need to work on the overridden Template buttons.
Source: https://ru.stackoverflow.com/questions/438190/
All Articles