Search code examples
c#.netmaui

.NET Maui Get screen Y and X


I cant seem to find how to get the screen size of the screen. I tried the Xamarin forms way:

mainDisplayInfo.Height;

Maui for windows doesnt work like this, anyone know how I can do this? Thanks!


Solution

  • Since Xamarin Essentials is now part of .NET MAUI as well, you should be able to get all the info you need with Microsoft.Maui.Devices.DeviceDisplay.MainDisplayInfo and all the properties in there like: Width and Height.

    More info here: https://learn.microsoft.com/dotnet/maui/platform-integration/device/display all APIs should be the same except for the namespace where they live.