【问题标题】:Windows 10 operating system issue with resolutionWindows 10 操作系统问题的解决方案
【发布时间】:2017-04-14 14:21:12
【问题描述】:

根据操作系统放置 UI 控件会导致不同的结果。下图显示了 Windows 10 的示例:

对于 Windows 7,我没有任何问题。

按钮和选项卡控件的 Xaml 代码(重叠):

     <Button  Grid.Column="1" Background="Transparent" Margin="0,0,18,0" HorizontalAlignment="Right" Height="30" Width="30"  VerticalAlignment="Center" BorderBrush="Transparent" Click="Settings_Click" Style="{DynamicResource ButtonStyle1}" >
                        <Button.ToolTip >
                            <TextBlock Margin="-7,-5" Padding="7,5" Foreground="White" Text="{Binding Configuration}" TextWrapping="Wrap"></TextBlock>
                        </Button.ToolTip>
                        <Image   Source="/Resources/017.png" ></Image>
                    </Button>
 <ContentControl Content="{Binding Mode=OneWay}" DataContext="{Binding ActiveVM}" Margin="-1,49,1,1" Grid.RowSpan="2"/>

【问题讨论】:

  • 我的水晶球说这与操作系统无关,与 DPI 设置有关。
  • 在较新版本的 Windows 标准“缩放”值设置为 125%,您可以在设置中更改。此设置可以完全改变 UI 的外观。编辑器(设计师)使用 100% 的“缩放”值,因此看起来会有所不同。 (“zoom”基本上是@CodyGray 写的,但在设置中它用“zoom”字命名)

标签: c# wpf


【解决方案1】:

将我的应用程序从 7 移到 10 时遇到了同样的问题。 看看这个线程: How to configure an app to run correctly on a machine with a high DPI setting (e.g. 150%)?

    private static extern bool SetProcessDPIAware(); 

是什么让我的应用再次看起来“正常”。

【讨论】:

  • 汉斯的回答非常清楚,正确的方法是适当地配置应用程序的清单。如果您无法更改清单(例如通过 ClickOnce 部署的应用程序),您应该 P/Invoke SetProcessDPIAware()。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-06-30
  • 2022-11-29
  • 1970-01-01
  • 2016-01-24
  • 1970-01-01
相关资源
最近更新 更多