Search code examples
c#wpfxamlitemscontrol

How do I bind a List<string> to an ItemsControl?


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?


Solution

  • let me answer this, it's just {Binding}.