【发布时间】:2019-01-11 04:05:31
【问题描述】:
我正在使用 WindowChrome 以一种简单快捷的方式重新设置窗口的样式,但问题是在调整窗口大小时会出现闪烁,尤其是在从左到右调整大小时。
<Window x:Class="View.Settings"
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"
mc:Ignorable="d"
Height="570" Width="800" WindowStartupLocation="CenterOwner"
Background="{StaticResource DarkGrayBackground}" ResizeMode="CanResize"
WindowStyle="SingleBorderWindow"
Title="Settings"
WindowState="Normal">
<WindowChrome.WindowChrome>
<WindowChrome
CaptionHeight="0"
CornerRadius="0"
GlassFrameThickness="1"
UseAeroCaptionButtons="False"
ResizeBorderThickness="5"
NonClientFrameEdges="None"/>
</WindowChrome.WindowChrome>
<Border BorderBrush="Black" BorderThickness="1">
<DockPanel HorizontalAlignment="Stretch" LastChildFill="True" Margin="0,0,0,0" VerticalAlignment="Stretch">
<!--TitleBar-->
<Border DockPanel.Dock="Top" BorderBrush="{StaticResource GrayBorder}" BorderThickness="0,0,0,1">
<Grid Height="40" Background="{StaticResource WhiteBackground}">
<DockPanel LastChildFill="False">
<Image DockPanel.Dock="Left" Margin="0,0,5,0" ></Image>
<Label DockPanel.Dock="Left" Content="{DynamicResource settings}" Margin="0,0,0,0" HorizontalAlignment="Center" VerticalAlignment="Center"></Label>
<Button DockPanel.Dock="Right" Style="{StaticResource CloseButton}" x:Name="CloseBtn"/>
</DockPanel>
</Grid>
</Border>
<!--Left Menu-->
<Border DockPanel.Dock="Left" Width="180" Background="{StaticResource GrayBackground}" BorderBrush="{StaticResource GrayBorder}" BorderThickness="0,0,1,0">
<DockPanel Margin="0,40,0,0" Width="180" LastChildFill="False">
<Button DockPanel.Dock="Top" Style="{StaticResource BigGrayButton}"
Content="{DynamicResource general}"/>
</DockPanel>
</Border>
<!--Bottom bar-->
<Border DockPanel.Dock="Bottom" BorderBrush="{StaticResource GrayBorder}" BorderThickness="0,1,0,0" Height="40" Background="{StaticResource WhiteBackground}">
<DockPanel LastChildFill="False">
</DockPanel>
</Border>
<!--Main Page-->
<ScrollViewer Background="{StaticResource DarkGrayBackground}" IsTabStop="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" DockPanel.Dock="Top">
<DockPanel LastChildFill="False" Margin="10,0,10,10">
<Label DockPanel.Dock="Top" Height="40" FontSize="16" FontWeight="SemiBold" VerticalContentAlignment="Center" Content="{DynamicResource general}"/>
<Frame DockPanel.Dock="top" x:Name="MainFrame"></Frame>
</DockPanel>
</ScrollViewer>
</DockPanel>
</Border>
当这部分 WindowChrome 被移除后一切恢复正常。
【问题讨论】:
-
我今天在应用了类似样式的应用程序中发现了同样的问题。有兴趣看看解决方案可能是什么。
-
我也是,效果一样。
-
如果气动按钮被禁用,为什么
GlassFrameThickness="1"在这里?ResizeBorderThickness="5"也可能导致调整大小问题 -
这里有同样的问题。看到解决方案会很有趣!
-
@l33t,如果您所说的“闪烁”是指 WPF 的默认 DWM 行为,那么 on SO 的阅读效果很好 - 无法修复它。除了我的系统,我没有其他问题。
标签: c# wpf window-chrome