即将GlassFrameThickness值设置为"0,0,0,1",此时即可获得阴影效果,此阴影效果为系统默认(测试系统是Win10)
参考链接:https://*.com/questions/5897495/shell-integration-library-windowchrome-with-drop-shadow
在MSDN没查到相关说明
备注:在测试中发现将ResizeMode直接写在Window标签属性上而不是以Style.Setter的方式赋值,当值为NoResize时,窗体会无阴影效果
xmlns:shell="clr-namespace:System.Windows.Shell;assembly=PresentationFramework"
<Window.Style> <Style TargetType="Window"> <Setter Property="UseLayoutRounding" Value="True"/> <Setter Property="ResizeMode" Value="NoResize"/> <Setter Property="shell:WindowChrome.WindowChrome"> <Setter.Value> <shell:WindowChrome CaptionHeight="80" GlassFrameThickness="0,0,0,1" ResizeBorderThickness="5" /> </Setter.Value> </Setter> <Style.Triggers> <DataTrigger Binding="{Binding DataContext.IsHomePage, RelativeSource={RelativeSource Self}}" Value="false"> <Setter Property="ResizeMode" Value="CanResize"/> </DataTrigger> </Style.Triggers> </Style> </Window.Style>