简要咨询咨询QQ网站导航网站搜索手机站点联系我们设为首页加入收藏 

XAML中Button重绘为圆形的方法技巧

来源:易贤网   阅读:1421 次  日期:2014-07-22 11:18:31

温馨提示:易贤网小编为您整理了“XAML中Button重绘为圆形的方法技巧”,方便广大网友查阅!

在用XAML布局的时候,有时候为了使界面Metro化,有些Button要使用圆形代替默认的长方形。以下的Button样式可以解决这个问题,可以根据自己的需要再加以修改。当然如果你熟悉Bland的话可以直接使用它来绘制你需要的样式,但是贴代码是否更快一点呢?

代码如下:

<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>

更多信息请查看IT技术专栏

更多信息请查看网页制作
点此处就本文及相关问题在本站进行非正式的简要咨询(便捷快速)】     【点此处查询各地各类考试咨询QQ号码及交流群
上一篇:如何在HTML中加载Flash(2种实现方法)
下一篇:checkbox的indeterminate属性使用介绍
易贤网手机网站地址:XAML中Button重绘为圆形的方法技巧
由于各方面情况的不断调整与变化,易贤网提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!