Page 1 of 1

Fit a window into XAML content

Posted: 23 Apr 2020, 08:39
by nikobarli
Hi,

I want to create a popup window populated with a XAML, and I want that window to fit the size of the XAML content.
How can I know the correct size for the window.

# In WPF I think I can use the property SizeToContent to let the window automatically adjust its size.

https://docs.microsoft.com/en-us/dotnet ... mework-4.8

thanks.

Re: Fit a window into XAML content

Posted: 23 Apr 2020, 13:15
by sfernandez
In the upcoming 3.0 version we implemented SizeToContent property in our Window implementation: #1631

Basically what we did is call Measure(INF, INF) on the content, and then AdjustWindowRect() to calculate the appropriate window size.

Re: Fit a window into XAML content

Posted: 25 Apr 2020, 10:31
by nikobarli
Basically what we did is call Measure(INF, INF) on the content, and then AdjustWindowRect() to calculate the appropriate window size.
Thank you. Will try to mimic that implementation. We are still using version 2.2 of NoesisGUI. I hope that will not block this feature.

Re: Fit a window into XAML content

Posted: 25 Apr 2020, 12:59
by jsantos
Yes, the implementation of displays in 3.0 should be compatible with 2.2. Please, try it at let us know. Thanks!