Skip to content

Visibility Issues with custom iOS control inside of SkiaMauiElement #372

Closed

Description

@sethom

In the attached example I have an iOS control complete with handlers (MyCustomControl). It just draws a simple rectangle and has a background color property. I've arranged 3 of these in a SkiaRow and I have a toggle visibility button for the second rectangle which is bound to a IsRectangleVisible property on the MainPageViewModel. Here's the code the comments I've added in XAML explain the problem for the 2nd two scenarios.

For the 2nd rectangle:

IsRectangleVisible is set to true on SkiaMauiElement in VM but fallback value of false. So, when VM loads it should become visible.
    When the page loads, space is allocated for SkiaMauiElement (it's visible), but MyCustomControl never appears even
    after toggling the visibility from the button.

For the 3rd rectangle:

MyCustomControl is visible even though IsVisible compiled to to false. 
    If I change to true, then hot-reload it, then back to false then hot-reload, it dissappears with 
    space still allocated for SkiaMauiElement (which seems correct)

Here's the broader code:

<d:SkiaRow>
    <d:SkiaMauiElement Grid.Row="0"  VerticalOptions="Fill" IsVisible="True"
                     HorizontalOptions="Fill"
                     Width="50"
                     Margin="20" 
                      HeightRequest="50">
        <meacontrols:MyCustomControl
            Margin="0, 0, 0, 0"
            VerticalOptions="Start"   
            HeightRequest="20"
            WidthRequest="50"
            CustomBackgroundColor="LawnGreen"
            HorizontalOptions="Fill"/>
    </d:SkiaMauiElement>
    <!--In this example, IsRectangleVisible is set to true in VM but fallback value of false. So, when VM loads it should become visible.
    When the page loads, space is allocated for SkiaMauiElement (it's visible), but MyCustomControl never appears even
    after toggling the visibility from the button.
    
    If however, recompile with VM _isRectangleVisible = false instead of true, everything works as expected.-->
    <d:SkiaMauiElement Grid.Row="0"  VerticalOptions="Fill"
         HorizontalOptions="Fill"
          Width="50"
          IsVisible="{Binding IsRectangleVisible, FallbackValue=False}"
          Margin="20" 
          HeightRequest="50"> 
        <meacontrols:MyCustomControl
            Margin="0, 0, 0, 0"
            VerticalOptions="Start"  
            IsVisible="True"
            HeightRequest="20"
            WidthRequest="50"
            CustomBackgroundColor="DarkBlue"
            HorizontalOptions="Fill"/> 
    </d:SkiaMauiElement>
    
    <!--In this example, MyCustomControl is visible even though IsVisible compiled to to false. 
    If I change to true, then hot-reload it, then back to false then hot-reload, it dissappears with 
    space still allocated for SkiaMauiElement (which seems correct)-->
    <d:SkiaMauiElement Grid.Row="0"  VerticalOptions="Fill" IsVisible="True"
         HorizontalOptions="Fill"
          Width="50"
          Margin="20" 
          HeightRequest="50"> 
        <meacontrols:MyCustomControl
            Margin="0, 0, 0, 0"
            VerticalOptions="Start"   
            IsVisible="False"
            HeightRequest="20"
            WidthRequest="50"
            CustomBackgroundColor="DarkMagenta"
            HorizontalOptions="Fill"/> 
    </d:SkiaMauiElement>
</d:SkiaRow>
<d:SkiaRow Grid.Row="1">
    <d:SkiaButton Grid.Row="1" Text="Toggle Visibility" Tapped="SkiaButton_Tapped"></d:SkiaButton>
    <d:SkiaLabel Margin="10, 0, 0, 0" Text="{Binding IsRectangleVisible, StringFormat='Visible: {0}'}" />
</d:SkiaRow>

I've attached the sample solution as well.

GameButtonDrawnUiTest.zip

Kind Regards!

Sean

Activity

  1. taublast commented on Oct 17, 2026

    @taublast
    Collaborator

    Hey Sean, thanks for the sample, I reproduced both cases.

    Please try the fix installing DrawnUi.Maui 1.10.7.12-pre1 (preview):

    • A SkiaMauiElement that starts hidden (like your binding with FallbackValue=False) now creates its native view when it becomes visible, and follows the binding after that.
    • The inner control's own IsVisible is respected now: IsVisible="False" keeps it hidden, and changing it at runtime shows or hides it, while a hidden SkiaMauiElement keeps it hidden anyway.

    Same fix is in for Android and Windows, please tell me if this nuget fixed it from your side, thanks!

  2. sethom commented on Oct 17, 2026

    @sethom
    Author

    I'll try it out as soon as I can. Probably a little later tonight.

    Thanks!

  3. sethom commented on Oct 18, 2026

    @sethom
    Author

    Everything works fine now, thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions