wpf 一个边框内阴影效果

xaml如下:

<Window x:Class="WPFTest.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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        Title="MainWindow"
        Height="450" 
        Width="800">
    <Grid Width="400" Height="200">
        <Grid.OpacityMask>
            <VisualBrush Visual="{Binding ElementName=Shape}" Stretch="None" />
        </Grid.OpacityMask>
        <Path x:Name="Shape" 
        Data="M98.765432,136.43836 L180.41152,1.6438356 262.05761,103.56164 343.7037,
              21.369863 470.12346,126.57534 596.54321,54.246575 551.76955,231.78082 638.68313,
              340.27397 528.06584,353.42466 525.4321,478.35616 391.11111,373.15068 285.76132,
              461.91781 217.28395,350.13699 135.63786,475.06849 114.5679,346.84932 1.3168724,
              251.50685 140.90535,212.05479 z" 
        Fill="White" Stroke="Blue" Stretch="Fill" />
        
        <Path Data="M98.765432,136.43836 L180.41152,1.6438356 262.05761,103.56164 343.7037,
              21.369863 470.12346,126.57534 596.54321,54.246575 551.76955,231.78082 638.68313,
              340.27397 528.06584,353.42466 525.4321,478.35616 391.11111,373.15068 285.76132,
              461.91781 217.28395,350.13699 135.63786,475.06849 114.5679,346.84932 1.3168724,
              251.50685 140.90535,212.05479 z" 
         Stroke="Green" StrokeThickness="1" Stretch="Fill">
            <Path.Effect>
                <DropShadowEffect ShadowDepth="0" BlurRadius="10" Color="#ffff0000"/>
            </Path.Effect>
        </Path>
    </Grid>
</Window>

效果如下:

Snipaste_2025-08-12_16-57-10

 

© 版权声明
THE END
喜欢就支持一下吧
点赞12 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情

    暂无评论内容