設定GlassFrameThickness為1,如果ResizeMode為NoResize,則ResizeMode屬性不能直接寫在Window標簽屬性上,要以Style.Setter的方式設定,否則沒有邊框陰影效果
代碼:
<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" WindowStyle="None" ShowInTaskbar="False" WindowStartupLocation="CenterScreen" Background="Transparent" Loaded="Window_Loaded"> <WindowChrome.WindowChrome> <WindowChrome CaptionHeight="60" GlassFrameThickness="1" UseAeroCaptionButtons="False" NonClientFrameEdges="None" CornerRadius="0"> </WindowChrome> </WindowChrome.WindowChrome> <Window.Resources> <ResourceDictionary> <!-- Window樣式 --> <Style TargetType="Window"> <!-- ResizeMode屬性不能直接寫在Window標簽屬性上,要以Style.Setter的方式設定,否則沒有邊框陰影效果 --> <Setter Property="ResizeMode" Value=https://www.cnblogs.com/s0611163/p/"NoResize"></Setter> </Style> </ResourceDictionary> </Window.Resources> <Grid> </Grid> </Window>View Code
上面的代碼似乎不管用,因為ResizeMode沒設定上,使用下面的代碼可以實作陰影效果且表單不可調整大小,但雙擊標題欄可以最大化
代碼:
<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
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/75426.html
標籤:WPF
