XAML中Button重绘为圆形的方法技巧
导读:收集整理的这篇文章主要介绍了XAML中Button重绘为圆形的方法技巧,觉得挺不错的,现在分享给大家,也给大家做个参考。 在用XamL布局的时候,有时候为了使界面Metro化,有些Button要使用圆形代替默认的长方形。以下的Bu...
收集整理的这篇文章主要介绍了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} " Vert@R_304_2411@Alignment="{ 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>
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: XAML中Button重绘为圆形的方法技巧
本文地址: https://pptw.com/jishu/587859.html