简体   繁体   English

UWP窗口内容不会随窗口大小调整

[英]UWP Window content doe not resize with window

I started to develop my first UWP App (just for fun). 我开始开发我的第一个UWP应用程序(只是为了好玩)。 While debugging I noticed that the content would not adapt correctly when resizing the window. 调试时我注意到在调整窗口大小时内容无法正确调整。 I started over with an empty app to see, if it was a general problem: it is. 我从一个空的应用程序开始,看看,如果这是一个普遍的问题:它是。

TL;DR: Why does this happen when resizing the window larger (beyond 1246x936 px)? TL; DR:为什么在调整窗口大小(超过1246x936像素)时会发生这种情况? Notice the issue on the very right. 注意问题就在右边。

注意问题就在右边

That's the XAML code: 这是XAML代码:

<Page
    x:Class="App2.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:local="using:App2"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    HorizontalAlignment="Stretch"
    VerticalAlignment="Stretch"
    mc:Ignorable="d">

    <Grid Background="White">
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition Width="3*" />
        </Grid.ColumnDefinitions>
        <Grid Grid.Column="0" Background="Blue" />
        <Grid Grid.Column="1" Background="Red" />
    </Grid>
</Page>

Little late but for posterity as this issue still comes up: 虽然这个问题仍然存在,但迟到了,但后代才出现:

This behavior is most likely related to UWP and your video drivers. 此行为很可能与UWP和您的视频驱动程序有关。 I have had this issue and it also extended into official Microsoft Windows Store UWP apps (Weather, Calc, etc) verifying it was not something I caused. 我有这个问题,它也扩展到官方的Microsoft Windows商店UWP应用程序(天气,计算等),验证它不是我造成的。

If you're lucky and have video driver updates, install them and it will likely fix the issue (it did for me on two different computers, one with an AMD card the other with Intel graphics). 如果你很幸运并有视频驱动程序更新,安装它们可能会解决问题(它在两台不同的计算机上为我做了,一台带有AMD卡,另一块带有英特尔显卡)。 If your video drivers are out of support there may not be a path forward (although the app would work on workstations whose drivers did render it correctly). 如果您的视频驱动程序不受支持,可能没有前进的路径(尽管该应用程序可以在其驱动程序确实正确呈现它的工作站上运行)。

There are a few tips on this thread that -may- work for workarounds for yourself (but aren't ideal if you're distributing your program and actually need it to render consistently). 这个帖子有一些提示 - 可能会为你自己做一些工作(但如果你正在分发你的程序并且实际上需要它一致地呈现,那么这些提示并不理想)。

https://superuser.com/questions/1376099/windows-10-uwp-not-rendering-fully https://superuser.com/questions/1376099/windows-10-uwp-not-rendering-fully

  • Run Performance Options (SystemPropertiesPerformance.exe) and uncheck "Show window contents while dragging". 运行性能选项(SystemPropertiesPerformance.exe)并取消选中“拖动时显示窗口内容”。 Then reboot. 然后重启。
  • Resize the window, then close and reopen the application, and it might then be of the right size. 调整窗口大小,然后关闭并重新打开应用程序,然后它可能是正确的大小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM