WPF Border圆角剪切

发布时间 2023-10-08 16:18:08作者: trykle

临时马上用,有空再封装
应该没有空

宽度为 100 注意匹配
圆角为 10 注意匹配
边框粗细为2
剪切的半径为11(圆角+边框粗细/2)

<Window
    x:Class="WpfApp2.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:local="clr-namespace:WpfApp2"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    Title="MainWindow"
    Width="800"
    Height="450"
    mc:Ignorable="d">
    <Grid>
        <Border
            Width="100"
            Height="100"
            CornerRadius="10">
            <Border.Clip>
                <RectangleGeometry
                    RadiusX="12"
                    RadiusY="12"
                    Rect="0,0,100,100" />
            </Border.Clip>
            <Image Source="E:\MaxScriptWork2020\Turing5Wpf\TrykleCgTool\bin\Debug\tools\101\icon.png" />
        </Border>
        <Border
            Width="100"
            Height="100"
            BorderBrush="Red"
            BorderThickness="2"
            CornerRadius="10" />
    </Grid>
</Window>