禁用布局缩放WINUI 3.0

发布于 2025-02-11 00:32:01 字数 92 浏览 0 评论 0原文

如何在Winui 3.0桌面应用程序中进行等效的UWP XAML UI的应用程序ViewScaling.trysetDisableLayoutscaling(true)?

How do I do the equivalent of UWP XAML UI's ApplicationViewScaling.TrySetDisableLayoutScaling(true) in a WinUI 3.0 Desktop application?

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

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

发布评论

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

评论(1

心头的小情儿 2025-02-18 00:32:01

Winui 3.0应用程序UI已经针对DPI缩放进行了调整,但媒体不是。如果您的屏幕尺寸为1080p,并且媒体为1080p,但是缩放率为125%,则媒体将大于屏幕尺寸,但是该应用程序将得到正确调整。如果您有很多媒体,则可能值得缩放根架。

要进行任何缩放,请执行以下操作,a)针对每个媒体作品本身或b)调整整个应用程序的缩放(根框架)。

要补偿任何缩放尺寸,请设置要缩放目标的x:名称;像根架或XAML IE x中的图像:name =“ root”。定位缩放的位置取决于您的规模和窗口,框架,页面的分离。最容易针对页面的加载覆盖功能中的根元素或图像。如果要调整框架,它必须是窗口的根元素,并且您可能会针对已驱逐的函数。这一切都取决于XAML中窗口,框架和页面之间的分离级别。必须在缩放之前加载XAML,因为必须将TypeInfo分配给元数据树。

使用root()。缩放(float3)进行缩放。要根据设备的缩放调整刻度,请调用root()。xamlroot()并获取栅格化刻度:

float rastScale =(float)root()root()。xamlroot()。rasterizationscalecalecalecalecalecalecale ()

使用:

root()。刻度({(1/rastscale),(1/rastScale),1.0f}),1.0f})

然后 实际上调用X:名称,而不是一些静态管道。您不能使用this-> xamlroot()将其返回null。您不能x:name获得xamlroot()的XAML类。

WinUI 3.0 Application UI's are already adjusted for DPI Scaling, but media is not. If your screen size is 1080p and media is 1080p, but scaling is 125%, the media will be larger than the screen size, but the app will be properly adjusted. If you have a lot of media, it might be worth scaling the root frame.

To do any scaling do the following and either a) target each media piece itself or b) adjust the scaling of your entire app(root frame).

To compensate for any scaling, set the x:Name of the target to be scaled; like a root frame, or an image in Xaml i.e. x:Name="root". Where you target the scaling depends on what you are scaling and the separation of your Window, Frame, Page. It's easiest to target the root element or image in the Loaded override function of the Page. If you want to adjust the Frame, it will have to be the root element of the Window and you'll probably target the overloaded function OnNavigated. It all depends on the level of separation between Window, Frame, and Page in Xaml. The Xaml has to be loaded before scaling can occur, because the TypeInfo has to be allocated to the MetaData Tree.

Scale using root().Scale(float3). To adjust scale based on the scaling of your device, call root().XamlRoot() and get the rasterization scale:

float rastScale = (float)root().XamlRoot().RasterizationScale()

Then set the scale with:

root().Scale({(1/rastScale), (1/rastScale), 1.0f})

When the documentation says XamlRoot, you are actually calling the x:Name, not some static plumbing. You cannot use this->XamlRoot() as this returns null. You cannot x:Name the Xaml Class to get XamlRoot().

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