Skip to content

Instantly share code, notes, and snippets.

@pocari
Last active May 14, 2022 23:42
Show Gist options
  • Save pocari/ef7778f1d67f568001e8 to your computer and use it in GitHub Desktop.
Save pocari/ef7778f1d67f568001e8 to your computer and use it in GitHub Desktop.
WPF Rounded Corner Button
<Style x:Key="RoundedButton" TargetType="{x:Type Button}">
<Style.Setters>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border x:Name="button" CornerRadius="5" BorderBrush="Black" BorderThickness="1" Background="Azure">
<TextBlock Text="{TemplateBinding Button.Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="button" Property="BorderBrush" Value="#FF5798d8" />
<Setter TargetName="button" Property="Background" Value="Red"/>
<Setter Property="Foreground" Value="White" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="button" Property="Background" Value="Green"/>
</Trigger>
<Trigger Property="IsFocused" Value="True">
<Setter TargetName="button" Property="BorderBrush" Value="#FF282828" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="button" Property="Opacity" Value="0.7" />
<Setter Property="Foreground" Value="Gray" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style.Setters>
</Style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment