Skip to content

Commit 4e6640a

Browse files
committed
Window positioning now on Mac Cat.
1 parent b24c6b1 commit 4e6640a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

docs/user-interface/controls/window.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,21 @@ Then, in the XML editor, open the **Platforms > iOS > Info.plist** file and the
230230
231231
## Position and size a Window
232232

233+
::: moniker range="=net-maui-8.0"
234+
233235
The position and size of a window can be programmatically defined for a .NET MAUI app on Windows by setting the `X`, `Y`, `Width`, and `Height` properties on a <xref:Microsoft.Maui.Controls.Window> object.
234236

235237
> [!WARNING]
236238
> Mac Catalyst doesn't support resizing or repositioning windows programmatically by setting the `X`, `Y`, `Width`, and `Height` properties.
237239
240+
::: moniker-end
241+
242+
::: moniker range=">=net-maui-9.0"
243+
244+
The position and size of a window can be programmatically defined for a .NET MAUI app on Mac Catalyst and Windows by setting the `X`, `Y`, `Width`, and `Height` properties on a <xref:Microsoft.Maui.Controls.Window> object.
245+
246+
::: moniker-end
247+
238248
For example, to set the window position and size on launch you should override the `CreateWindow` method in your `App` class and set the `X`, `Y`, `Width`, and `Height` properties on a <xref:Microsoft.Maui.Controls.Window> object:
239249

240250
```csharp
@@ -269,6 +279,8 @@ Window.Y = (displayInfo.Height / displayInfo.Density - Window.Height) / 2;
269279

270280
For information about obtaining the device's screen metrics, see [Device display information](~/platform-integration/device/display.md).
271281

282+
::: moniker range="=net-maui-8.0"
283+
272284
### Mac Catalyst
273285

274286
Mac Catalyst doesn't support resizing or repositioning windows programmatically. However, a workaround to enable resizing is to set the `MinimumWidth` and `MaximumWidth` properties to the desired width of the window, and the `MinimumHeight` and `MaximumHeight` properties to the desired height of the window. This will trigger a resize, and you can then revert the properties back to their original values:
@@ -289,6 +301,8 @@ Dispatcher.Dispatch(() =>
289301
});
290302
```
291303

304+
::: moniker-end
305+
292306
## Decouple window management from the App class
293307

294308
Window management can be decoupled from the `App` class by creating a class that implements the <xref:Microsoft.Maui.Controls.IWindowCreator> interface, and adding your window management code in the <xref:Microsoft.Maui.Controls.IWindowCreator.CreateWindow%2A> method:

0 commit comments

Comments
 (0)