WPF调整Windows大小

Jef*_*eff 3 .net wpf resize resolution touchscreen

我维护一个触摸屏应用程序,我正在重写.Net.多年来,触摸屏的分辨率大大提高.不仅分辨率更高,而且像素也更密集,使得更难以看到/操作触摸按钮.

WPF是否有办法强制应用程序窗口在分辨率/像素密度变化时扩大规模?我宁愿不必每隔几年重修这些屏幕.

Gan*_*ant 5

就在这里.

您可以使用WPF的ViewBox包装容器.这是一个例子:

<Window x:Class="TestWPF.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300">

    <Viewbox Stretch="Uniform">
        <StackPanel Background="Azure" Height="400" Width="300" Name="stackPanel1" VerticalAlignment="Top">
            <Button Name="testBtn" Width="200" Height="50">
                <TextBlock>Test</TextBlock>
            </Button>
        </StackPanel>
    </Viewbox>

</Window>
Run Code Online (Sandbox Code Playgroud)

截图: 在此输入图像描述

有关详细信息,请参阅此主题.