In winui 3, how to bind to a dependency property of my UserControl, inside a DataTemplate of a contained ItemsControl?
Voyageur Solitaire
1
Reputation point
So I have a UserControl, which contains an ItemsControl. I need the controls defined inside the DataTemplate to bind to a dependency property in my UserControl.
Let's say my UserControl has a dependency property MyProp. I want to do the following in my xaml code...
<UserControl>
...
<ItemsControl>
<ItemsControl.ItemTemplate>
<DataTemplate x:DataType="MyType">
<custom:ControlThatExpectsMyType
SomeProperty={x:Bind MyProp}>
</custom:ControlThatExpectsMyType>
</DataTemplate>
<ItemsControl.ItemTemplate>
</ItemsControl>
...
</UserControl>
The MyProp dependency property in the above snippet is not part of MyType, but of my UserControl. Both Binding and x:Bind are acceptable solutions, but none of the "old wpf ways" seem to be working in winui 3.
So, what's the proper -expected- way to do it in winui 3?
Sign in to answer