How can I get a screen resolution of Device (Windo

2019-01-27 14:49发布

How can I get a screen resolution of Device from settings (Windows Phone) ?

4条回答
爷的心禁止访问
2楼-- · 2019-01-27 15:09

This may be a better way to know what screen resolution is your app running on.

if(App.Current.Host.Content.ScaleFactor == 100)
{
  // WVGA
}
else if (App.Current.Host.Content.ScaleFactor == 160)
{
  // WXGA
}
else if (App.Current.Host.Content.ScaleFactor == 150)
{
  // 720p
}

Source http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj206974%28v=vs.105%29.aspx

查看更多
看我几分像从前
3楼-- · 2019-01-27 15:09

This actually requires a combination of @Dmitriy Reznik and @Paras Wadehra's answers, as the dimensions exposed by Host.Content are the unscaled dimensions.

var content = App.Current.Host.Content;

var screenResolution = new Size(
    content.ActualWidth*content.ScaleFactor/100,
    content.ActualHeight*content.ScaleFactor/100);
查看更多
我想做一个坏孩纸
4楼-- · 2019-01-27 15:15
public void GetScreenResolution()  
{  
     string ScreenWidth = Application.Current.Host.Content.ActualWidth.ToString();  
     string ScreenHeight = Application.Current.Host.Content.ActualHeight.ToString();  
     MessageBox.Show(ScreenWidth + "*" + ScreenHeight);  
}  
查看更多
Deceive 欺骗
5楼-- · 2019-01-27 15:24
登录 后发表回答