taublast / DrawnUi.Maui

UI Rendering Engine for .NET MAUI powered by SkiaSharp
MIT License
216 stars 16 forks source link

Canvas doesn't render in MAUI app on initial load #103

Open taublast opened 6 days ago

taublast commented 6 days ago

Discussed in https://github.com/taublast/DrawnUi.Maui/discussions/98

<views:Canvas Gestures="Enabled" HeightRequest="60" x:Name="Canvas" Grid.Row="1">
            <controls:ColorSlider HeightRequest="50" SelectedColor="{Binding SliderColor, Mode=OneWayToSource}"/>
</views:Canvas>

Originally posted by @nathenxbrewer October 24, 2024

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.

So here we have a situation that both Canvas and container layout inside have auto-size. The issue is that after measurement the measured layout size is not taken into consideration by the Canvas to adapt to measured content size.

To be fixed.

taublast commented 4 days ago

@nathenxbrewer can you please share your xaml regarding the Grid? I see you have Grid.Row="1" so.. Or maybe you slider is different from the Sandbox one?

i tried to repro with the following, but no luck, canvas shows okay:

    <!--tried without definitions, same..-->
    <Grid RowDefinitions="80,*">

        <draw:Canvas
            x:Name="Canvas"
            Grid.Row="1"
            Gestures="Enabled"
            HeightRequest="60">
            <!--  one from the Sandbox project  -->
            <controls:SliderColor HeightRequest="50" />
        </draw:Canvas>

    </Grid>
taublast commented 7 hours ago

i have a feeling this might fix it, to be verified when repro is available: #c6687bdffb21b2949d2fc8b633aee311ba9d3222