首页 > 解决方案 > 带有 WindowChrome 调整大小问题的 WPF 窗口

问题描述

将这个简单的 XAML 用于自定义窗口。它工作正常,除了在调整大小时(从左、上、左上和左下)看起来很糟糕。窗口像疯了一样闪烁。看起来不像是操作系统问题,因为微软的玻璃 Windows 应用程序可以像黄油一样平滑地调整大小。

我正在尝试自定义窗口框架,但除非我使用 WindowChrome,否则我会丢失所有调整大小、拖动等操作。

<Window x:Class="WpfApp2.MainWindow"
        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:WpfApp2"
        WindowStyle="None"
        mc:Ignorable="d"
        WindowStartupLocation="CenterScreen"
        Title="MainWindow" Height="450" Width="600">
    <WindowChrome.WindowChrome>
        <WindowChrome GlassFrameThickness="1,1,1,1" />
    </WindowChrome.WindowChrome>
    <Border BorderBrush="Red" BorderThickness="1">
        <Button Content="Test" Height="25" Width="75" />
    </Border>
</Window>

标签: c#wpf

解决方案


推荐阅读