question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mac Catalyst does not support resizing or repositioning windows programmatically

See original GitHub issue

Description

Setting a windows width/height or setting window X/Y does not actually update the window’s frame.

This appears to be a limitation in the Mac Catalyst approved APIs.

See also #4942

Steps to Reproduce

  1. Set Window.Width = 400
  2. Observe nothing happens

Version with bug

Unknown/Other (please specify)

Last version that worked well

Unknown/Other

Affected platforms

macOS

Affected platform versions

Mac Catalyst

Did you find any workaround?

There may be a potential workaround by setting the Min/Max coordinates and then reverting it. Not perfect, but seems to work OK.

Window.MinimumWidth = 700;
Window.MaximumWidth = 700;

Window.MinimumHeight = 500;
Window.MaximumHeight = 500;

// dispatcher is used to give the window time to actually resize
Dispatcher.Dispatch(() =>
{
	Window.MinimumWidth = 0;
	Window.MaximumWidth = double.PositiveInfinity;
	Window.MinimumHeight = 0;
	Window.MaximumHeight = double.PositiveInfinity;
});

Relevant log output

No response

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
headintheclouds21commented, Nov 8, 2022

With this Hanlder it works:

         Microsoft.Maui.Handlers.WindowHandler.Mapper.AppendToMapping(nameof(IWindow),
             (handler, view) =>
        {
#if MACCATALYST
                 var size = new CoreGraphics.CGSize(600, 400);
                 handler.PlatformView.WindowScene.SizeRestrictions.MinimumSize = size;
                 handler.PlatformView.WindowScene.SizeRestrictions.MaximumSize = size;
#endif
        });

I’m using .NET 7 and this is not working for me. I’ve placed it in the app.xaml.cs file with no luck. Has anyone had success with this?

0reactions
jinxinjuancommented, Aug 7, 2023

Verified this issue with Visual Studio for Mac 17.6.2 (build 414). Can repro on macOS platform.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mac Catalyst - control window resize
On Mac, I want to control window resizing, in order to allow only some sizes and aspects. It goes beyond simple minimal height...
Read more >
How do you set an OSX app's window size and detect ...
In a non document based App, I had issues with window resize and reposition: I wanted the window to be displayed with size...
Read more >
NET MAUI windows
Mac Catalyst doesn't support resizing or repositioning windows programmatically by setting the X , Y , Width , and Height properties.
Read more >
Windows Sizing & Positioning in .NET MAUI
In this article you will learn how to do it very quickly! ... ➖Mac Catalyst does not support resizing or repositioning windows using...
Read more >
Mac OS X: How to resize a window by dragging from the ...
I am back to using Mac OS X but it is driving me nuts how you can only change the size of the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found