1. 程式人生 > >uwp - 獲取當前螢幕寬高/應用寬高

uwp - 獲取當前螢幕寬高/應用寬高

原文: uwp - 獲取當前螢幕寬高/應用寬高

  

public static Size GetScreen()
        {
            var applicationView = ApplicationView.GetForCurrentView();
            var displayInformation = DisplayInformation.GetForCurrentView();
            var bounds = applicationView.VisibleBounds;
            var scale = displayInformation.RawPixelsPerViewPixel;
            var size = new Size(bounds.Width * scale, bounds.Height * scale);
            return size;
            
        }
//double width = GetScreen().Width;當前螢幕寬度
//double height = GetScreen().Height;當前螢幕高度