Why hasn't the .NET WinUI 3 team added support for AncestorType binding inside the DataTemplate or ControlTemplate? #10394
Unanswered
Abdulsaboorhabibi
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
It would be really helpful to have the ability to bind to parent or ancestor elements directly within a template, especially when trying to reference properties or data of higher-level elements like Page or UserControl.
For instance, if I wanted to bind a property from the Page or UserControl to a control inside a DataTemplate, it would be great to directly use something like AncestorType or AncestorLevel in the Binding. But currently, we can't do that directly. Here's an example scenario:
Example Scenario:
Imagine we have a UserControl that has a ListView in it, and each ListViewItem is part of a DataTemplate. In the DataTemplate, I would like to bind a TextBlock's Text property to a property from the parent UserControl (for example, a Title property). But as it stands, WinUI 3 doesn't directly support AncestorType inside a DataTemplate. Here's what I would love to do:
Instead, we can achieve this by explicitly setting up a Binding in the parent container (e.g., the UserControl), which can be tedious and less intuitive.
Why hasn't the WinUI 3 team implemented this?
Beta Was this translation helpful? Give feedback.
All reactions