• 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>
    View Code
  • 相关阅读:
    PHP生成二维码并上传到七牛云
    算法入门---选择排序
    算法入门
    react入门-refs
    react入门-props.children
    react入门-组件方法、数据和生命周期
    react入门-jsx
    递归
    node的path.join 和 path.resolve的区别
    vuex的使用
  • 原文地址:https://www.cnblogs.com/fuchongjundream/p/4180273.html
Copyright © 2020-2023  润新知