Adjustify minimium width and height to all devices

Dani_S 2,846 Reputation points
2023-10-20T06:43:28.8+00:00

Hi,

How i adjustify minimium width and height to all devices in net 7 ,window platform?

Thanks,

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,960 questions
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 36,871 Reputation points Microsoft Vendor
    2023-10-23T09:06:49.7633333+00:00

    Hello,

    In MAUI, you could use DeviceDisplayInfo to get the width and height of your device.

    In the following example code, determine whether the width and height of the Editor control exceed the width and height of the screen.

    protected override void OnAppearing()
    {
        base.OnAppearing();
        MainThread.BeginInvokeOnMainThread(async () => await DelayedShowWidth());
    }
    private async Task DelayedShowWidth()
    {
        await Task.Delay(500);
        if (testEditor.Width >= DeviceDisplay.MainDisplayInfo.Width
             || testEditor.Height >= DeviceDisplay.MainDisplayInfo.Height)
        {
            Console.WriteLine("out of screen");
            // do something.
        }
        else
        {
            // do something.
        }
    }
    

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful