手机
当前位置:查字典教程网 >网页设计 >XHTML >XAML中Button重绘为圆形的方法技巧
XAML中Button重绘为圆形的方法技巧
摘要:在用XAML布局的时候,有时候为了使界面Metro化,有些Button要使用圆形代替默认的长方形。以下的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>

【XAML中Button重绘为圆形的方法技巧】相关文章:

在HTML中引入CSS的3种方式使用介绍

html中使用margin:0 auto整个页面不居中的解决方法

改变HTML下拉框SELECT选项的多种方法

HTML中select下拉框内容显示不全部分被覆盖的解决方法

向div元素添加圆角边框的实现方法

disabled不可输入的值无法传递到action层

html title里面加双引号的实现方法

HTML实现遮罩层的方法 HTML中如何使用遮罩层

【HTML 元素】嵌入图像的实现方法

HTML 隐藏滚动条和去除滚动条的方法

精品推荐
分类导航