.Net MAUI

Windows Sizing & Positioning in .NET MAUI

When developing your desktop applications in .NET MAUI, you can control both the size and position of your application windows. In this article you will learn how to do it very quickly!


Let’s start!

Preparing the stage

First of all, you have to override the CreateWindows Method which allow you to handle the Window’s settings. Go to your App.xam.cs and add it! To overwrite it faster, apply the following steps:

➖ Type “override Create” and press Enter or Tab button twice.

➖ This will complete the base structure of the method.

Next, let’s access the window information using a variable, as shown in the following code:


Sizing your Windows

You already have the stage prepared, now you only have to add the properties. To modify the size of your window, you only have to access the Width and Height properties, as I show you below:

We also have properties that help us control the minimum or maximum values ​​of the width or height of the screen which are the following:

➖MaximumHeight and MaximumWidth: Sets the maximum value that the screen can reach in width or height respectively. (Receives a double as value)

➖MinimumHeight and MinimumWidth: Sets the minimum value that the screen can reach in width or height respectively. (Receives a double as value)


Positioning your Windows

Finally, to position your Windows you can access the X and Y properties as follows:


🚫 Limitations

➖Mac Catalyst does not support resizing or repositioning windows using the above.


And done!! ? From now on, you are ready to play with the size and position of your application windows in .NET MAUI! I hope you liked it! 💚💕

<Label Text=”Thanks for ready! 👋 ” />
.
.
Tagged

3 thoughts on “Windows Sizing & Positioning in .NET MAUI

Leave a Reply

Your email address will not be published. Required fields are marked *