zoukankan      html  css  js  c++  java
  • WPF Window无边框窗体阴影效果

    设置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="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
  • 相关阅读:
    HDU 1527 取石子游戏 (威佐夫博奕)
    HDU 1159 Common Subsequence (LCS)
    HDU 1160 FatMouse's Speed (LIS)
    HDU 2577 How to Type (DP)
    csu 1395: Timebomb (模拟)
    csu 1556: Jerry's trouble(大数取模)
    csu 1553: Good subsequence (最长连续子序列)
    csu 1548: Design road (三分)
    csu 1547: Rectangle (01背包)
    csu 1541: There is No Alternative(Kruskal 最小生成树)
  • 原文地址:https://www.cnblogs.com/s0611163/p/13691740.html
Copyright © 2011-2022 走看看