CommunityToolkit / Maui

The .NET MAUI Community Toolkit is a community-created library that contains .NET MAUI Extensions, Advanced UI/UX Controls, and Behaviors to help make your life as a .NET MAUI developer easier
https://learn.microsoft.com/dotnet/communitytoolkit/maui
MIT License
2.2k stars 380 forks source link

[BUG] DrawingView does not render correctly after tab navigation (TabBar) #2078

Open Ghibytzu opened 1 month ago

Ghibytzu commented 1 month ago

Is there an existing issue for this?

Did you read the "Reporting a bug" section on Contributing file?

Current Behavior

In a MAUI app, when using a TabBar structure for the UI, on application startup DrawingView is rendered correctly and all the controls work as expected. However after navigating to SecondaryPage (tab) and back to the MainPage (tab) the DrawingView is not rendered correctly anymore.

Expected Behavior

DrawingView remains rendered correctly during TabBar navigation.

Steps To Reproduce

  1. Open and run the solution from the reproduction repository on Windows machine.
  2. Observe the DrawingView control.
  3. (optional) Interact with Drawing View control.
  4. Navigate to Secondary tab.
  5. Navigate to Main tab.

Link to public reproduction project repository

https://github.com/Ghibytzu/DrawingViewWithTabBarNet8/tree/master

Environment

- .NET MAUI CommunityToolkit: 9.0.2
- OS: Windows 11 Build 10.0.22631.3880
      Android Emulator pixel 5 api 33
- .NET MAUI: 8.0.61

Anything else?

Important Note: There is a similar issue on Android, after navigation the DrawingView remains rendered but cannot be accessed. E.g. method DrawingView.ClearI() does not clear the content and other controls ignore DrawingView's position. Screenshot_1722443778

Important Note2: Also, I tried the same code on .NET MAUI CommunityToolkit: 6.1.0 with .NET Framework 7.0 and the issue does not reproduce: DrawingView works as expected during tab navigation (TabBar).

Additional debugging steps performed I tried several methods like overriding the OnAppearing() method of the Content page but with no avail:

   protected override void OnAppearing()
    {
        base.OnAppearing();
        ReinitializeDrawingView();
    }

        private void ReinitializeDrawingView()
    {
        if (!MainLayout.Children.Contains(drawView))
        {
            MainLayout.Children.Insert(0, drawView);
        }
    }

After navigation DrawingView has IsVisible = true but IsLoaded = false and is not rendering on screen.

vplife1 commented 4 weeks ago

@Ghibytzu Facing the same issue have you found any workaround ??

vplife1 commented 4 weeks ago

https://github.com/CommunityToolkit/Maui/issues/2153