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

前端 未结 4 1866
南方客
南方客 2020-12-20 13:39

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

相关标签:
4条回答
  • 2020-12-20 14:20

    That solution will work on WP7.x and WP8 devices: http://sviluppomobile.blogspot.co.at/2013/04/detect-screen-resolution-for-windows.html

    0 讨论(0)
  • 2020-12-20 14:20

    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);
    
    0 讨论(0)
  • 2020-12-20 14:23
    public void GetScreenResolution()  
    {  
         string ScreenWidth = Application.Current.Host.Content.ActualWidth.ToString();  
         string ScreenHeight = Application.Current.Host.Content.ActualHeight.ToString();  
         MessageBox.Show(ScreenWidth + "*" + ScreenHeight);  
    }  
    
    0 讨论(0)
  • 2020-12-20 14:40

    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

    0 讨论(0)
提交回复
热议问题