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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM