WPF常用控件样式集锦

1、不规则形状按钮(通过更改path实现)

WPF常用控件样式集锦
        <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>
View Code

 

WPF常用控件样式集锦

上一篇:模拟队列


下一篇:vue-cli3.0配置跨域 基操