gpt4 book ai didi

c# - WPF WindowChrome 在调整大小时导致闪烁

转载 作者:可可西里 更新时间:2023-11-01 08:12:26 28 4
gpt4 key购买 nike

我正在使用 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 被删除时,一切都会恢复正常。

最佳答案

您的问题是由设置为 NONE 的 NonClientFrameEdges 属性引起的。此属性获取或设置一个值,该值指示窗口框架的哪些边缘不属于客户端并且至少一个边缘必须属于客户端。

因此将您的代码更改为:

NonClientFrameEdges="Right"

这将解决您的问题。

关于c# - WPF WindowChrome 在调整大小时导致闪烁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51669632/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com