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

Edward Tanguay picture Edward Tanguay · Sep 8, 2009 · Viewed 17.4k times · Source

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?

Answer

Edward Tanguay picture Edward Tanguay · Sep 8, 2009

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