You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/user-interface/controls/window.md
+14Lines changed: 14 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -230,11 +230,21 @@ Then, in the XML editor, open the **Platforms > iOS > Info.plist** file and the
230
230
231
231
## Position and size a Window
232
232
233
+
::: moniker range="=net-maui-8.0"
234
+
233
235
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.
234
236
235
237
> [!WARNING]
236
238
> Mac Catalyst doesn't support resizing or repositioning windows programmatically by setting the `X`, `Y`, `Width`, and `Height` properties.
237
239
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
+
238
248
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:
For information about obtaining the device's screen metrics, see [Device display information](~/platform-integration/device/display.md).
271
281
282
+
::: moniker range="=net-maui-8.0"
283
+
272
284
### Mac Catalyst
273
285
274
286
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(() =>
289
301
});
290
302
```
291
303
304
+
::: moniker-end
305
+
292
306
## Decouple window management from the App class
293
307
294
308
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