在 Windows 商店应用程序中获取窗口宽度/高度 [英] Get window width / height in Windows store apps
问题描述
我目前有一个加载的基本页面,我需要某种方式来获取窗口的宽度和高度,最好是在构造函数中.问题是,在构造函数中,或者在页面完全加载之前,我似乎无法掌握宽度和高度.加载后我可以使用:
I currently have a basic page which loads, and I need some way of obtaining the width and height of the window, preferably in the constructor. The problem is, in the constructor, or before the page is completely loaded, I can't seem to get hold of the width and height. After it is loaded I can just use:
this.ActualWidth;
this.ActualHeight;
是否有我可以使用的任何窗口加载完成事件或任何方法来获取加载过程中的宽度和高度?
Is there any window load complete event I can use or any way to obtain the width and height during the loading?
推荐答案
您可以随时使用属性 Window.Current.Bounds.有关更多详细信息,请阅读:如何获取屏幕分辨率?对于 WinRT 应用?
You can find out the size of the Window at any moment using the property Window.Current.Bounds. For more details, read: How to get the resolution of screen? For a WinRT app?
这篇关于在 Windows 商店应用程序中获取窗口宽度/高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!