Skip to content

Question: ElementName binding doesn't work in EntranceThemeTransition #2054

@aosyatnik

Description

@aosyatnik

I'm not sure if it's a bug or I'm doing something wrong. In order to reproduce it you will need source code: https://github.com/aosyatnik/UWP_ElementNameBinding_Issue

Steps to reproduce:

  1. Build and run the app. You will see a list of 10 numbers and "Redraw" button.
  2. Click on "Redraw" button. See, that the whole list is updated at once.
  3. Go to \Themes\Generic.xaml and fine next code:
<TransitionCollection>
   <!-- THIS BINDING IS NOT WORKING -->
   <EntranceThemeTransition IsStaggeringEnabled="{Binding ElementName=Items, Path=DataContext.IsStaggeringEnabled}"
                            FromVerticalOffset="-20"
                            FromHorizontalOffset="-20" />

   <!--<EntranceThemeTransition IsStaggeringEnabled="True"
                                FromVerticalOffset="-20"
                                FromHorizontalOffset="-20" />-->
</TransitionCollection>
  1. Comment the first EntranceThemeTransition and uncomment the second EntranceThemeTransition. Code should look like this:
<TransitionCollection>
   <!-- THIS BINDING IS NOT WORKING -->
   <!--<EntranceThemeTransition IsStaggeringEnabled="{Binding ElementName=Items, Path=DataContext.IsStaggeringEnabled}"
                                FromVerticalOffset="-20"
                                FromHorizontalOffset="-20" />-->

   <EntranceThemeTransition IsStaggeringEnabled="True"
                            FromVerticalOffset="-20"
                            FromHorizontalOffset="-20" />
</TransitionCollection>
  1. Click on "Redraw" and see how each item is updated with animation one by one.

Question:

Why binding of IsStaggeringEnabled is not working? IsStaggeringEnabled is presented in MainViewModel and set to true. The view model is bind to UI and I can see a collection of numbers, so the view model is working.

Stackoverflow:

I also asked on stackoverflow, but people are suggesting to use x:Bind, but I can not do it, because it's templated control, do I?

https://stackoverflow.com/questions/60207057/uwp-elementname-binding-doesnt-work-in-entrancethemetransition

Possible duplicate of #560 .

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-winui-3Indicates that feature can only be done in WinUI 3.0 or beyond. (needs winui 3)no-issue-activity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions