WPF: Bind DataGrid to List<String>

Posted by Sam on Stack Overflow See other posts from Stack Overflow or by Sam
Published on 2010-05-20T10:36:10Z Indexed on 2010/05/20 10:40 UTC
Read the original article Hit count: 178

Filed under:
|
|

Funny, how sometimes the simple things bite me in the behind.

I can bind a DataGrid nicely to a Collection of some arbitrary class, using a DataGridTextColumn like this:

<DataGridTextColumn Header="Name" Binding="{Binding Name}"/>

Now I want to bind a DataGrid to a simple Collection. So since there is no property "Name" or something like that to bind to, how do I write the binding:

<DataGridTextColumn Header="Name" Binding="{Binding ???}"/>

String has no Property "Value" or something like that. And if I just write {Binding } I'll end up with a one-way-binding, unable to write changes back to the Collection.

Thinking about it, I think it is not possible to bind to a collection, so I do need to wrap my string into a class?
Or is there a way?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about binding