Canvas doesn't render in MAUI app on initial load #98
-
I'm trying to consume a SkiaSlider using the Canvas. For some reason, when the app loads, the Canvas is not rendered. If I change the xaml in any way, the app will Hot Reload and the canvas is then rendered. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments
-
Hi please can you share your xaml? Please also note the platform. |
Beta Was this translation helpful? Give feedback.
-
I had it inside of an Expander view. Once I removed the Expander, the Canvas now draws on first load. .NET 8 MAUI - iOS, haven't tested on Android yet |
Beta Was this translation helpful? Give feedback.
-
As i see both canvas and its content (controls:ColorSlider) do not present any width constraint. If do not set either canvas horizontaloptions="fill" either widthrequest="something" it would try to adapt its width to content. So actually, this is by design. Again as stated in readme:
|
Beta Was this translation helpful? Give feedback.
-
Regarding the point of canvas being inside expander.. Might affect the measurement indeed, Canvas auto-size is purely "custom-made" (as is measures virtual drawn controls) we might have some conflicts between MAUI controls and drawn controls. |
Beta Was this translation helpful? Give feedback.
-
Yup, adding HorizontalOptions="Fill" did the trick. Thanks! |
Beta Was this translation helpful? Give feedback.
-
Converted to issue #103 and this "by design" thingy has to be fixed :) |
Beta Was this translation helpful? Give feedback.
As i see both canvas and its content (controls:ColorSlider) do not present any width constraint.
If do not set either canvas horizontaloptions="fill" either widthrequest="something" it would try to adapt its width to content.
So if Colorsilder has no fixed with in that case you might see this behaviour. I suspect your content has horizontaloptions="fill" so with an auto-sized canvas that might present an issue for the first measurement.
So actually, this is by design. Again as stated in readme: