-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Width and Height getters on Window returns NaN on Mac #18060
Comments
You should always listen to Bounds -> RenderSize and not listen to (Width and Height) -> requested size |
@Gillibald I am not sure if that's the case with Window Height/Width. |
The FrameSize/ClientSize should always be set in the end |
This feels like a misleading API then. Perhaps the properties should be made private, or renamed (to something like If this is "by design", it's not a very good design, imho. |
The XML docs here could use some improvement. Avalonia/src/Avalonia.Base/Layout/Layoutable.cs Lines 222 to 238 in 98a388d
WPF says it more accurately: Keep in mind that all layout properties on a control are suggestions: parent layout controls are free to completely ignore them if they wish although good ones comply as much as possible. This design is almost 20 years old from WPF, so it's both well-known and backwards-compatible. UWP follows the same. On Maui, there's |
I agree on the xml comments. It should also explain what NaN means for the system. |
So Xamarin.Forms / MAUI actually made some changes in this area. They have Avalonia follows WPF which is fine most of the time but doesn't make it completely clear in all cases like MAUI. I still prefer WPF/Avalonia naming for the brevity though. You just have to remember Height/Width are a request at the end of the day. In WPF you would be reading
|
I see. On Windows, Should the behavior on Windows change to match Mac, then? |
…requested" size rather than actual size (see AvaloniaUI#18060)
I don't think so, as different platforms have different window managers and we can't make all of them behave the same. |
* Added new test: changing window size should not change position * Removed unnecessary window placement assignment to fix window position shifting due to incorrect workspace coordinate usage * Fixed test because buttons went off the window on tiny screen resolutions * Make test Windows specific * Use `Bounds` instead of `Width` and `Height` properties as they are "requested" size rather than actual size (see #18060)
Describe the bug
On Mac, the getters for
Width
andHeight
are returningNaN
instead of the actual window size, when the size is not already set. It seems the difference between Windows and Mac is that on Mac, there is no entry inValueStore._effectiveValues
for it.To Reproduce
Create a window where the xaml doesn't contain
Width=".." Height=".."
. For example:Print the
Width
andHeight
anywhere:Expected behavior
On Windows,
Width
andHeight
are the actual window size. On Mac, the returned values are bothNaN
.Avalonia version
master
OS
macOS
Additional context
This popped up when writing an integration test for #18004. I have not tested the behavior on Linux.
The text was updated successfully, but these errors were encountered: