WPF 控件自定义背景

 
         <!--控件要设置尺寸的话,设置的尺寸必须比下面的图形的尺寸要小,不然显示不开-->
        <Label  Content="直角测试"  Width="90" Height="90" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Margin="359,207,283,62" >
            <Label.Background>
                <VisualBrush >
                    <VisualBrush.Visual>
                        <Path   Stroke="Red" SnapsToDevicePixels="True" StrokeThickness="3" >
                            <Path.Data>
                                <PathGeometry>
                                    <PathFigure StartPoint="0,0">
                                        <!--折线图-->
                                        <PolyLineSegment  Points="100,0 100,90 55,90 50,100 45,90 0,90 0,0"></PolyLineSegment>
                                    </PathFigure>
                                </PathGeometry>
                            </Path.Data>
                        </Path>
                    </VisualBrush.Visual>
                </VisualBrush>
            </Label.Background>
        </Label>


        <Label  Content="圆角测试" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Margin="16,273,653,20"  >
            <Label.Background>
                <VisualBrush Stretch="Fill">
                    <VisualBrush.Visual>
                        <Path Stroke="Red" StrokeThickness="2" Stretch="UniformToFill">
                            <Path.Data>
                                <PathGeometry>
                                    <!--路径开始点-->
                                    <PathFigure StartPoint="5,0">
                                        <!--线段-->
                                        <LineSegment Point="95,0"></LineSegment>
                                        <!--弧形-->
                                        <ArcSegment Point="100,5" Size="5,5" SweepDirection="Clockwise"></ArcSegment>
                                        <!--线段-->
                                        <LineSegment Point="100,85"></LineSegment>
                                        <!--弧形-->
                                        <ArcSegment Point="95,90" Size="5,5" SweepDirection="Clockwise"></ArcSegment>
                                        <!--折线-->
                                        <PolyLineSegment Points="55,90 50,100 45,90 5,90"></PolyLineSegment>
                                        <!--弧形-->
                                        <ArcSegment Point="0,85" Size="5,5" SweepDirection="Clockwise"></ArcSegment>
                                        <!--线段-->
                                        <LineSegment Point="0,5"></LineSegment>
                                        <!--弧形-->
                                        <ArcSegment Point="5,0" Size="5,5" SweepDirection="Clockwise"></ArcSegment>
                                    </PathFigure>
                                </PathGeometry>
                            </Path.Data>
                        </Path>
                    </VisualBrush.Visual>
                </VisualBrush>
            </Label.Background>
        </Label>

效果图
image

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值