本文介绍了如何实现在XAML一个圆圈按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何实现像在XAML下面一个圆形按钮,没有任何外在形象要求。无需黑线在中间
How to implement a circle button like below one in XAML, no external image required.The black line in the middle is not needed.
推荐答案
这是一个非常快速的方式来做到这一点。它可以通过创建一个TemplatedControl使设计人员能够轻松地改变颜色等性质改变成一种风格,它可以更灵活。
This is a very quick way to do it. It can be changed into a style and it could be made more flexible by creating a TemplatedControl allowing the designer to easily change the colors and other properties.
<Button Width="100"
Height="100">
<Button.Template>
<ControlTemplate TargetType="Button">
<Grid>
<Ellipse Stroke="Black"
StrokeThickness="2">
<Ellipse.Fill>
<RadialGradientBrush>
<GradientStop Offset="0"
Color="Lime" />
<GradientStop Offset="1"
Color="Lime" />
<GradientStop Offset="1"
Color="Gold" />
<RadialGradientBrush.Transform>
<TransformGroup>
<ScaleTransform ScaleY="0.65" />
</TransformGroup>
</RadialGradientBrush.Transform>
</RadialGradientBrush>
</Ellipse.Fill>
</Ellipse>
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Grid>
</ControlTemplate>
</Button.Template>
</Button>
这篇关于如何实现在XAML一个圆圈按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!