漂亮的删除按钮样式(显示出来的是一个红色的叉)

本文详细介绍了按钮的样式设计过程,包括按钮的模板、尺寸、背景颜色和形状的设定,以及如何通过XAML代码实现这些样式。同时,文章还展示了按钮的交互效果,如悬停时的提示文字变化。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 <Style x:Key="ButtonDelete" TargetType="{x:Type Button}">
        <Setter Property="ToolTip" Value="删除" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid x:Name="grid"
                          Width="35"
                          Height="25"
                          Background="Transparent">
                        <Path Margin="5"
                              HorizontalAlignment="Center"
                              VerticalAlignment="Center"
                              Data="M264,144"
                              Stretch="Fill"
                              Stroke="Black">
                            <Path.Fill>
                                <LinearGradientBrush StartPoint="1.235,0.757" EndPoint="0.417,-0.421">
                                    <GradientStop Offset="0" Color="Black" />
                                    <GradientStop Offset="1" Color="White" />
                                </LinearGradientBrush>
                            </Path.Fill>
                        </Path>
                        <Path Margin="5"
                              HorizontalAlignment="Center"
                              VerticalAlignment="Center"
                              Data="M224,184"
                              Stretch="Fill"
                              Stroke="Black">
                            <Path.Fill>
                                <LinearGradientBrush StartPoint="1.235,0.757" EndPoint="0.417,-0.421">
                                    <GradientStop Offset="0" Color="Black" />
                                    <GradientStop Offset="1" Color="White" />
                                </LinearGradientBrush>
                            </Path.Fill>
                        </Path>
                        <Path x:Name="path1"
                              Width="10"
                              Height="10"
                              Margin="5"
                              HorizontalAlignment="Center"
                              VerticalAlignment="Center"
                              Data="M225.0616,221.49152 C225.06182,221.49163 284.52632,154.87505 314.0474,155.72765 314.0474,155.72765 232.45547,247.64286 232.45547,247.64286 223.21292,258.03906 206.39212,266.66986 206.33998,259.15356 206.18145,236.2969 225.06137,221.4914 225.0616,221.49152 z"
                              Stretch="Fill">
                            <Path.Fill>
                                <LinearGradientBrush MappingMode="RelativeToBoundingBox" StartPoint="0.5,0" EndPoint="0.5,1">
                                    <GradientStop Offset="0.991" Color="White" />
                                    <GradientStop Offset="0.978" Color="Brown" />
                                </LinearGradientBrush>
                            </Path.Fill>
                        </Path>
                        <Path x:Name="path2"
                              Width="10"
                              Height="10"
                              Margin="5"
                              HorizontalAlignment="Center"
                              VerticalAlignment="Center"
                              Data="M287.98419,227.19702 C303.37484,251.26958 307.12677,273.98902 304.43574,272.18989 L291.25169,250.54466 C277.25079,231.44142 232.86561,190.06773 213.9081,174.02543 205.90815,158.02543 208.69505,150.19498 225.74176,159.28198 239.86099,166.80844 252.9268,182.20368 265.64616,197.93196"
                              RenderTransformOrigin="0.608,0.503"
                              Stretch="Fill">
                            <Path.Fill>
                                <LinearGradientBrush MappingMode="RelativeToBoundingBox" StartPoint="0.5,0" EndPoint="0.5,1">
                                    <GradientStop Offset="1" Color="White" />
                                    <GradientStop Offset="0.017" Color="Brown" />
                                    <GradientStop Offset="0.996" Color="Brown" />
                                </LinearGradientBrush>
                            </Path.Fill>
                        </Path>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

转载于:https://www.cnblogs.com/shyyj/archive/2012/02/09/2344144.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值