【发布时间】:2013-03-08 22:06:44
【问题描述】:
我遇到了问题,希望得到专家的帮助。我正在尝试获取屏幕分辨率,以便可以根据手机类型使用适当的布局/图像。
我的项目类型是 WP7。每当我在不同的 WP7 和 WP8 设备上运行代码时,我每次都得到相同的分辨率(800 X 480)。预期的行为是我根据设备类型获得不同的分辨率,例如WVGA = 800 x 480,WXGA = 1280 x 768,720p = 1280 x 720。
下面的所有 3 个代码 sn-ps 都给了我相同的 800 X 480 分辨率,这不是预期的行为。
Application.Current.RootVisual.RenderSize.Height + " x " + Application.Current.RootVisual.RenderSize.Width;
(App.Current.RootVisual as FrameworkElement).ActualHeight + " x " + (App.Current.RootVisual as FrameworkElement).ActualWidth;
App.Current.Host.Content.ActualHeight + " x " + App.Current.Host.Content.ActualWidth;
MSDN 文章讨论了如何在 WP8 中执行此操作,但请注意我希望代码也可以在 WP7 设备上运行。
【问题讨论】:
标签: windows-phone-7 windows-phone