aokocax Software developer, develops tools and projects, likes startups.

Finding the full width of the screen in .net MAUI.

Especially when we want a view to have full width in the screen, we need to know the width of the screen in terms of DPU/DPR. It's not possible to do this with a fixed number as Full WidthRequest is different on each device. By learning the Density of the device in MAUI, you can learn the required number to have full width with WidthRequest;
var pixelWidth=DeviceDisplay.Current.MainDisplayInfo.Width; //pixel width
var density=DeviceDisplay.Current.MainDisplayInfo.Density; // density
var fullWidthRequest=pixelWidth/density; //FullWidthRequest


Press ESC to close