-
-
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. |
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: