In my presenter I have this property:
public List<string> PropertyNames { get; set; }
And I want to list out the names with a ItemsControl/DataTemplate like this:
<ItemsControl ItemsSource="{Binding PropertyNames}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Value}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Since the generic list doesn't have named properties, how do I reference the value in my Binding statement?
let me answer this, it's just {Binding}
.
An easier way to accomplish the same thing is to simply use:
<ItemsControl ItemsSource="{Binding PropertyNames}"/>
By default, this will create a vertical StackPanel and add each element in its own TextBlock. According to MSDN, this works for any of the following:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With