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

Summary of methods for inserting videos into HTML pages

Now if you want to use the video tag in a page, y...

Pure HTML and CSS to achieve JD carousel effect

The JD carousel was implemented using pure HTML a...

How to view image information in Docker

In this article, we will need to learn how to vie...

MySQL uses variables to implement various sorting

Core code -- Below I will demonstrate the impleme...

Docker installation of MySQL (8 and 5.7)

This article will introduce how to use Docker to ...

Detailed explanation of MySQL cumulative calculation implementation method

Table of contents Preface Demand Analysis Mysql u...

Implementation of fuzzy query like%% in MySQL

1, %: represents any 0 or more characters. It can...

Detailed explanation of the difference between alt and title

These two attributes are often used, but their di...

How to Install Xrdp Server (Remote Desktop) on Ubuntu 20.04

Xrdp is an open source implementation of Microsof...

Summary of Vue's monitoring of keyboard events

Key Modifiers When listening for keyboard events,...

Encapsulate a simplest ErrorBoundary component to handle react exceptions

Preface Starting from React 16, the concept of Er...

Detailed steps for using AES.js in Vue

Use of AES encryption Data transmission encryptio...

Summary of MySql index, lock, and transaction knowledge points

This article summarizes the knowledge points of M...