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;当前屏幕高度

  

猜你喜欢

转载自www.cnblogs.com/lonelyxmas/p/9919876.html
UWP