WPF Window无边框窗体阴影效果

WPF通过WindowChrome实现Window无边框窗体阴影效果

代码:

<Window x:Class="SunCreate.PACP.Client.UI.GIS.CameraDetailsWin"
        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"
        xmlns:local="clr-namespace:SunCreate.PACP.Client.UI"
        mc:Ignorable="d"
        Title="CameraDetailsWin" Height="780" Width="1200" Loaded="Window_Loaded"
        WindowStyle="None" ResizeMode="CanResize" ShowInTaskbar="False" WindowStartupLocation="CenterScreen" Background="Transparent">
    <WindowChrome.WindowChrome>
        <WindowChrome CaptionHeight="60"
                      GlassFrameThickness="1"
                      UseAeroCaptionButtons="False"
                      NonClientFrameEdges="None"
                      CornerRadius="0"
                      ResizeBorderThickness="0">
        </WindowChrome>
    </WindowChrome.WindowChrome>
    <Grid>
        
    </Grid>
</Window>
    
View Code

Windows设置:

关键点:

GlassFrameThickness="1"

ResizeMode="CanResize"

ResizeBorderThickness="0"

效果:窗体有阴影,窗体不能调整大小,但是双击标题栏可以最大化

注意:不能设置AllowsTransparency="True",否则无法播放视频 

 

参考博客:https://www.cnblogs.com/dino623/p/CustomWindowStyle.html

 

posted @ 2020-09-18 15:58  0611163  阅读(2389)  评论(2编辑  收藏  举报