Skip to content

TemplatedParent not resolved correctly in Button.Flyout #1884

Closed

Description

@juliecantin

Current behavior

Inside the content of a Button.Flyout, a binding with TemplatedParent as the RelativeSource will fail.

Expected behavior

A binding with TemplatedParent will resolve correctly.

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

https://github.com/jcantin-nventive/templated-parent-binding
Launch the app and click on the "Click me" button

  • On UWP, the value displayed is 5, which is expected

  • On iOS/Android, the value displayed is "The binding has failed", which accurately describes the situation.

The crux of the issue is the custom control style

Environment

Nuget Package:

Package Version(s): 1.45.0

Affected platform(s):

  • iOS
  • Android
  • WebAssembly
  • WebAssembly renderers for Xamarin.Forms
  • Windows
  • Build tasks
  • Solution Templates

Visual Studio:

  • 2017 (version: 15.9.11)
  • 2019 (version: )
  • for Mac (version: )

Relevant plugins:

  • Resharper (version: )

Anything else we need to know?

Activity

  1. added
    kind/bug
    triage/untriaged
    on Oct 17, 2019
  2. added
    platform/android 🤖
    platform/ios 🍎
    and removed
    triage/untriaged
    on Oct 18, 2019
  3. modified the milestone: 3.1 on Aug 29, 2020
  4. added
    project/binding 🪢
    on Sep 15, 2020
  5. added
    project/animations 🎡
    and removed
    project/animations 🎡
    on Sep 21, 2020
  6. added
    difficulty/tbd
    on Feb 15, 2021
  7. added
    difficulty/medium 🤔
    and removed
    difficulty/tbd
    on Jun 1, 2021
  8. amaid commented on Nov 15, 2021

    @amaid

    This issue also exists in WASM where TemplatedParent isn't being resolved correctly in WASM but working in UWP

    Repro steps:

    1. Create an ContentControl.
    2. Define datatemplate for the ContentTemplate and bind it to any TemplatedParent property, in my case its just simple string.
      as follows:

    XAML:

    <ContentControl x:Name="MainContent" HorizontalContentAlignment="Stretch" Grid.Row="1">
                <ContentControl.ContentTemplate>
                    <DataTemplate>
                        <TextBlock Foreground="#000000" Text="{Binding Path=DataContext, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay,FallbackValue='Binding failed'}"/>
                    </DataTemplate>
                </ContentControl.ContentTemplate>
            </ContentControl>

    Output
    image

  9. added
    area/popups 💬
    on Jan 26, 2022
  10. self-assigned this
    on Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/popups 💬difficulty/medium 🤔kind/bugplatform/android 🤖platform/ios 🍎project/binding 🪢

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions