在WPF中使用125%的DPI设置裁剪按钮边框

时间:2020-01-07 15:28:34

标签: wpf dpi groupbox highdpi

当我在Windows中使用125%DPI设置时,有时不呈现按钮边框。它似乎取决于大小和位置,也许还取决于按钮的父元素:

enter image description here

在我的应用程序中,我还可以在WPF设计器中看到,尽管按钮本身较大,但父边框的尺寸似乎太小。也许测量过程某种程度上是错误的:

enter image description here

我尝试更改整个窗口的UseLayoutRounding,也更改SnapsToDevicePixels没有帮助。 清单中设置了DPI意识。

有人知道如何为整个应用程序解决此问题吗?

这就是默认Wpf Window应用程序中的代码(我现在无法重现该问题,但问题仍然存在于我的应用程序中):

<Window x:Class="WpfApp3.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"
        mc:Ignorable="d"
        Title="MainWindow"
        SizeToContent="WidthAndHeight">

    <StackPanel>
        <GroupBox>
            <GroupBox.Header>
                <Button Width="20"
                        Height="22"
                        Content="X" />
            </GroupBox.Header>
        </GroupBox>

        <Button Width="20"
                Height="22"
                VerticalAlignment="Center"
                HorizontalAlignment="Left"
                Content="X" />
    </StackPanel>
</Window>

0 个答案:

没有答案
相关问题