unoplatform / uno

Build Mobile, Desktop and WebAssembly apps with C# and XAML. Today. Open source and professionally supported.
https://platform.uno
Apache License 2.0
8.77k stars 706 forks source link

[iOS, Android] DrawerControl.DrawerContent isn't set on mobile but works on win #12624

Open Lee31416 opened 1 year ago

Lee31416 commented 1 year ago

Current behavior

image

On mobile we can see the overlay but the drawer content is nowhere to be found

Expected behavior

image

On windows we can see that the drawer content is there

How to reproduce it (as minimally and precisely as possible)

  1. Download the sample SampleDrawerEdgeSwipe.zip
  2. Deploy the sample on windows
  3. Swipe with the mouse or click on the button to open the pane
  4. Deploy on either ios or android
  5. Swipe or click the button to open the pane and see that the content isn't there

Workaround

None found

Works on UWP/WinUI

Yes

Environment

Uno.UI / Uno.UI.WebAssembly / Uno.UI.Skia, Uno.UI.RemoteControl / Uno.WinUI.RemoteControl

NuGet package version(s)

4.8.15

Affected platforms

Android, iOS

IDE

Visual Studio 2019

IDE version

17.6.2

Relevant plugins

No response

Anything else we need to know?

Before we used a drawer control but we had issues with it so we switched to a split view but the native splitview doesn't have gestures so we took the DrawerSplitViewStylestyle and that's when the bug appeared. So maybe the combination of a drawer control inside a splitview is causing this issue.

Xiaoy312 commented 1 year ago

This is the result of {TemplateBinding} not applying properly in uno: #1621 The nested template doesnt inherit the proper templated-parent, for the binding to work:

ContentControl#DrawerTemplate_DrawerContentControl // TemplatedParent=DrawerControl#SplitView_TemplateRoot, Content=ContentControl#Drawer_PaneHolder
    ContentPresenter // TemplatedParent=ContentControl#DrawerTemplate_DrawerContentControl, Content=ContentControl#Drawer_PaneHolder
        ContentControl#Drawer_PaneHolder // TemplatedParent=DrawerControl#SplitView_TemplateRoot, Content= // <--
            ContentPresenter // TemplatedParent=ContentControl#Drawer_PaneHolder, Content=
templates are slightly modified to help identify element (click here to see details) ```

^ the Drawer_PaneHolder here is supposed to have SplitView#RootSplitView for its templated-parent, as it is defined directly under the control-template for SplitView.

Xiaoy312 commented 1 year ago

The very same problem can also be produced with XamlReader.Load, hints that the problem is how we handles {TemplateBinding} or {Binding RelativeSource={RelativeSource TemplatedParent}}. However, it is impossible to trace-back under which control-template it was define under, as we can't just blindly navigate up by n-levels. We will have to do as the linked issue suggested, to inject the relevant context/templated-parent during the xaml-source-generation or XamlReader-loading.