实现简单的按钮图标,鼠标移上时显示框,本样式只专注于图案,文字要另外调整ContentPresenter的位置
<Style x:Key="refresh_Btn" targettype="button"> <Setter Property="@R_502_5095@" Value="3"/> <Setter Property="borderThickness" Value="1"/> <Setter Property="borderBrush" Value="#005FADDD" /> <Setter Property="Background" Value="transparent" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate targettype="button"> <GrID> <visualstatemanager.VisualStateGroups> <VisualStateGroup x:name="CommonStates"> <VisualState x:name="normal"/> <VisualState x:name="MouSEOver"> <Storyboard> <colorAnimation Duration="0:0:0.5" To="#FF5FADDD" Storyboard.TargetProperty="(border.borderBrush).(SolIDcolorBrush.color)" Storyboard.Targetname="Background" /> </Storyboard> </VisualState> <VisualState x:name="pressed" /> <VisualState x:name="Disabled"> <Storyboard> <DoubleAnimation Duration="0" To=".55" Storyboard.TargetProperty="Opacity" Storyboard.Targetname="DisabledVisualElement"/> </Storyboard> </VisualState> </VisualStateGroup> <VisualStateGroup x:name="Focusstates"> <VisualState x:name="Focused"> <Storyboard> <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.Targetname="FocusVisualElement"/> </Storyboard> </VisualState> <VisualState x:name="Unfocused"/> </VisualStateGroup> </visualstatemanager.VisualStateGroups> <border x:name="Background" borderBrush="{TemplateBinding borderBrush}" borderThickness="{TemplateBinding borderThickness}" Background="transparent" CornerRadius="0"> <GrID Background="{TemplateBinding Background}" margin="1"> <Path x:name="PathIcon" Data="...(省略)" Fill="#036EB8" HorizontalAlignment="Center" VerticalAlignment="Center"> </Path> </GrID> </border> <ContentPresenter x:name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" margin="{TemplateBinding @R_502_5095@}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/> <Rectangle x:name="DisabledVisualElement" Fill="#FFFFFFFF" IsHitTestVisible="false" Opacity="0" RadiusY="3" RadiusX="3"/> <Rectangle x:name="FocusVisualElement" IsHitTestVisible="false" margin="1" Opacity="0" RadiusY="2" RadiusX="2" stroke="{x:Null}" strokeThickness="0"/> </GrID> </ControlTemplate> </Setter.Value> </Setter></Style>
记录此方法,为日后项目中使用
---- 记录完毕 -----
总结以上是内存溢出为你收集整理的利用Path路径设计的按钮图标(Silverlight)全部内容,希望文章能够帮你解决利用Path路径设计的按钮图标(Silverlight)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)