Create Buttons With Rounded Corner In WPF

Create Buttons With Rounded Corner In WPF

Mishel Shaji
Mishel Shaji

In this post, we'll learn to create buttons with rounded corners in WPF.

The default button template in WPF has a border. So, we have to change value of the CornerRadius property of the border in the button template.

Single Button With Rounded Corners

If you want rounded corners for a single button, modify the XAML code as shown below.

<Button Content="Button">
		<Style TargetType="Border">
			<Setter Property="CornerRadius" Value="10"></Setter>

Apply to all Buttons

To apply rounded corners to all buttons in the application, add this style in the App.xaml file in the Application.Resources tag.

    <Style TargetType="Button">
        <Setter Property="Template">
                <ControlTemplate TargetType="Button">
                    <Border CornerRadius="10"
                            Margin="{TemplateBinding Padding}" ></ContentPresenter>

Here is a screenshot of the result.

Happy coding ūüĎć