WPF中的圆角按钮 [英] Round corner button in WPF
本文介绍了WPF中的圆角按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何修改代码以使按钮的角变圆?
Hi,
How should I modify my code to make the corners of my button rounded?
<UserControl x:Class="WindowsFormsApplication8.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="154" Width="177">
<Grid>
<Rectangle Name="rectangle1" Stroke="Black" RadiusX="10" RadiusY="10" >
</Rectangle>
<Button Name="rectangle2" Foreground="Black" Margin="3,3,3,3" >
<Button.Background >
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
<GradientStop Color="Green" Offset="0.0" />
<GradientStop Color="White" Offset="0.9" />
</LinearGradientBrush>
</Button.Background>
</Button>
</Grid>
</UserControl>
最简单的方法是什么?
What is the simplest way?
推荐答案
要获得圆角,必须使用控制模板.
我已经在我的博客中对此进行了解释:
http://tarundotnet.wordpress.com/2011/02/22 /a-rounded-edged-button-in-wpf/ [
To get round edged corners, you have to use a control template.
I have explained that in my blog :
http://tarundotnet.wordpress.com/2011/02/22/a-rounded-edged-button-in-wpf/[^]
Hope it helped!
看看这篇文章:圆形样式Glassy WPF按钮 [^ ]
Have a look at this article: A Style for Round Glassy WPF Buttons[^]
这篇关于WPF中的圆角按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文