出于某种原因,我需要在页面构造函数中获得设备屏幕高度,并使用它来设置其他页面项的大小。我这样做:
double screenHeight = Application.Current.RootVisual.RenderSize.Height;但是,我最近检测到,如果应用程序是从tombstoning出来的,并且这个页面是活动页面,那么这段代码就会失败。在这种情况下,Application.Current.RootVisual是空的。
如何克服这一点,还是有其他方法来获得屏幕高度?
发布于 2014-07-31 09:22:56
实际上,Application.Current.RootVisual.RenderSize返回屏幕分辨率。如果这是您想要的,请使用Application.Current.Host.Content.ActualHeight:
double screenHeight = Application.Current.Host.Content.ActualHeight;https://stackoverflow.com/questions/25040126
复制相似问题