我维护着一个触摸屏应用程序,我正在将其重写到 .Net 中。多年来,触摸屏的分辨率已大大提高。不仅分辨率更高,而且像素也更密集,因此更难看到/操作触摸按钮。
WPF 有没有一种方法可以强制应用程序窗口随着分辨率/像素密度的变化而自行变大?我宁愿不必每隔几年就重新加工这些屏幕。
最佳答案
是的,有。
您可以使用 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>
截图:
咨询this topic了解更多信息。
关于.net - WPF 调整窗口大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/701101/