WPF 调整窗口大小

发布于 2024-07-16 07:26:27 字数 158 浏览 4 评论 0原文

我维护一个触摸屏应用程序,并将其重写到.Net 中。 多年来,触摸屏的分辨率已大大提高。 不仅分辨率更高,而且像素也更密集,使得查看/操作触摸按钮变得更加困难。

WPF 有没有办法强制应用程序窗口随着分辨率/像素密度的变化而自行缩放? 我不想每隔几年就重新设计这些屏幕。

I maintain a touch screen application that I'm re-writing into .Net. Through the years the resolution of the touch screens has increased greatly. Not only is the resolution higher, but the pixels are also much more dense making it harder to see/operate the touch buttons.

Is there a way with WPF to force application windows to scale themselves larger as resolutions/pixel density changes? I'd rather not have to rework these screens every few years.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

木森分化 2024-07-23 07:26:27

就在这里。

您可以使用 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>

屏幕截图:
在此处输入图像描述

咨询此主题了解更多信息。

Yes, there is.

You can wrap your container with WPF's ViewBox. Here goes the example:

<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>

Screenshot:
enter image description here

Consult this topic for more info.

客…行舟 2024-07-23 07:26:27

这是默认行为,每个 WPF“像素”是 1/96 英寸,而不是实际像素(现在唯一的问题是,几乎所有屏幕都设置为 96DPI,无论屏幕实际分辨率如何)。

This is the default behavior, each WPF "pixel" is 1/96 of an inch and not an actual pixel (now the only problem is that virtually all screens are set to 96DPI regardless of the screen actual resolution).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文