9

I have a wpf application that is designed for a 1900x1200 resolution but some of our users have used the windows display settings to resize everything by 125%-150%, is there a way to have an application ignore those settings and still display normally?

I have seen something called SetProcessDPIAware here, but havent had any luck with it.

Here is a screen shot of the application with the display scaling turned up to 150% Application with Scaling

As you can see the application is way too small and there is no way to get it to be correctly sized.

4

2 回答 2

4

在这种情况下,Dpi 意识将无济于事。它只会改变 CompositionTarget.TransformToDevice 矩阵,但控件大小不会改变。

我使用视图框来缩放所有内容。我的应用程序中的所有尺寸都是为 Surface Pro 3 纵向设计的:

<Window>
    <Viewbox Stretch="Uniform">
        <Grid Width="1440" Height="2160">
            <!-- ... -->
        </Grid>
    </Viewbox>
</Window>

您可以根据屏幕 DPI 计算视图框大小。看到这个答案:https ://stackoverflow.com/a/12414433/991267

于 2014-10-23T20:49:57.893 回答
1

忽略 dpi 的新方法是:

右键单击您的项目

添加 > 新项目

找到“应用程序清单文件(仅限 Windows)

在第 55 行取消注释,或找到 dpiAware

  <application xmlns="urn:schemas-microsoft-com:asm.v3">
    <windowsSettings>
      <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
      <longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
    </windowsSettings>
  </application>
于 2021-09-11T19:15:34.037 回答