首页 > 代码库 > WPF常用控件样式集锦
WPF常用控件样式集锦
1、不规则形状按钮(通过更改path实现)
<Style x:Key="ButtonStyleForPath" TargetType="{x:Type Button}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Grid x:Name="grid" RenderTransformOrigin="0.5,0.5"> <Grid.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform/> <TranslateTransform/> </TransformGroup> </Grid.RenderTransform> <Path Name="BtnShape" Stretch="Uniform" Fill="#FF0C96DF" > <Path.Data> <PathGeometry FillRule="Nonzero" Figures="M35.953125,28.1245803833008L100.359375,64.9214553833008 35.953125,101.718330383301 35.953125,28.1245803833008z" /> </Path.Data> </Path> <ContentPresenter x:Name="contentPresenter" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content=""/> </Grid> <ControlTemplate.Triggers> <Trigger Property="IsFocused" Value="True"/> <Trigger Property="IsDefaulted" Value="True"/> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="RenderTransform" TargetName="grid"> <Setter.Value> <TransformGroup> <ScaleTransform ScaleX="1.05" ScaleY="1.05"/> <SkewTransform/> <RotateTransform/> <TranslateTransform/> </TransformGroup> </Setter.Value> </Setter> </Trigger> <Trigger Property="IsPressed" Value="True"> <Setter Property="Fill" TargetName="BtnShape" Value="#FF00A7FF"> <!--<Setter.Value> --><!--<RadialGradientBrush> <GradientStop Color="White" Offset="0"/> <GradientStop Color="#FF0C96DF" Offset="1"/> </RadialGradientBrush>--><!-- </Setter.Value>--> </Setter> </Trigger> <Trigger Property="IsEnabled" Value="False"/> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style>
WPF常用控件样式集锦
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。