How to redraw Button as a circle in XAML

How to redraw Button as a circle in XAML
When using XAML layout, sometimes in order to make the interface Metro-like, some buttons need to use circles instead of the default rectangles. The following Button style can solve this problem and can be modified according to your needs. Of course, if you are familiar with Bland, you can use it directly to draw the style you need, but is it faster to paste the code?

Copy code
The code is as follows:

<Style x:Key="btnNext" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Pressed">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="rectangle">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Thickness>-3</Thickness>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Normal"/>
<VisualState x:Name="Disabled"/>
<VisualState x:Name="MouseOver"/>
</VisualStateGroup>
<VisualStateGroup x:Name="FocusStates">
<VisualState x:Name="Focused"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Rectangle x:Name="rectangle" RadiusY="25" RadiusX="25" Stroke="Blue" StrokeThickness="4">
</Rectangle>
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Margin" Value="5"/>
<Setter Property="Width" Value="50"/>
<Setter Property="Height" Value="50"/>
<Setter Property="FontSize" Value="120"/>
<Setter Property="Foreground" Value="White"/>
</Style>

<<:  Detailed explanation of VUE's data proxy and events

>>:  Two ways to understand CSS priority

Recommend

CentOS 8 is now available

CentOS 8 is now available! CentOS 8 and RedHat En...

Detailed analysis of the usage and application scenarios of slots in Vue

What are slots? We know that in Vue, nothing can ...

mysql5.7.17.msi installation graphic tutorial

mysql-5.7.17.msi installation, follow the screens...

Implementing a simple whack-a-mole game in JavaScript

This article shares the specific code for JavaScr...

Write a formal blog using XHTML CSS

The full name of Blog should be Web log, which me...

Handtrack.js library for real-time monitoring of hand movements (recommended)

【Introduction】: Handtrack.js is a prototype libra...

ul list tag design web page multi-column layout

I suddenly thought of this method when I was writi...

How to forget the password of Jenkins in Linux

1.Jenkins installation steps: https://www.jb51.ne...

How to delete node_modules and reinstall

Table of contents Step 1: Install node_modules in...

HTML Basics: HTML Content Details

Let's start with the body: When viewing a web ...

Add ico mirror code to html (favicon.ico is placed in the root directory)

Code: Copy code The code is as follows: <!DOCTY...

Three ways to refresh iframe

Copy code The code is as follows: <iframe src=...