Answer the question
In order to leave comments, you need to log in
How to change button color after clicking?
There is a task: to make it so that when you click on the button, its background changes. Made the following code:
<Style x:Key="BackColor" TargetType="{x:Type Button}">
<Setter Property="Foreground" Value="White"/>
<Setter Property="FontSize" Value="50"/>
<Setter Property="Content" Value="SEND"/>
<Setter Property="Background" Value="#FF06C548"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="FontFamily" Value="Global User Interface"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border CornerRadius="17" Background="{TemplateBinding Background}">
<ContentPresenter
HorizontalAlignment="Center"
VerticalAlignment="Center"
Height="63"
Margin="192,17,177,10"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#FF0EAC44"/>
</Trigger>
<Trigger Property ="ClickMode" Value="Release">
<Setter Property="Background" Value="#FF1B74CB"/>
</Trigger>
</Style.Triggers>
</Style>
Answer the question
In order to leave comments, you need to log in
figured it out myself
<Style x:Key="BackColor" TargetType="{x:Type Button}">
<Setter Property="Foreground" Value="White"/>
<Setter Property="FontSize" Value="50"/>
<Setter Property="Content" Value="SEND"/>
<Setter Property="Background" Value="#FF06C548"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="FontFamily" Value="Global User Interface"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border CornerRadius="17" Background="{TemplateBinding Background}">
<ContentPresenter
HorizontalAlignment="Center"
VerticalAlignment="Center"
Height="63"
Margin="192,17,177,10"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<EventTrigger RoutedEvent="MouseEnter">
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="(Button.Background).(SolidColorBrush.Color)"
To="#FF0EAC44"
Duration="0:0:0.4"
FillBehavior="HoldEnd"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="MouseLeave">
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="(Button.Background).(SolidColorBrush.Color)"
To="#FF06C548"
Duration="0:0:0.4"
FillBehavior="HoldEnd"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="Click">
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="(Button.Background).(SolidColorBrush.Color)"
To="#FF1B74CB"
Duration="0:0:0.4"
FillBehavior="HoldEnd"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Style.Triggers>
</Style>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question