Presenting collection of structures of strings in grid or similar in WPF - Example? Ideas?
Posted
by Andrew
on Stack Overflow
See other posts from Stack Overflow
or by Andrew
Published on 2010-05-21T22:25:11Z
Indexed on
2010/05/21
22:30 UTC
Read the original article
Hit count: 244
Hi,
I have a collection of structures. The structure is just some strings. Example public struct ReportLine { public string Name; public string Address; public string Phone; ...// about 10 other strings } I can't change this part. What I want to do is display it in a simple grid or simlar in WPF. My only requirements are: a) need column headers b) rows must alternate in color c) columns big enough to hold largest datum (which is not know until run time)
Can someone point me to an example to get me started? Is the GridView the way to go? Or DataGrid? Or perhaps just the grid?
I have the book Pro WPF in C# 2008 and it covers binding ListBox's to collections, but the collections always seem to be collections of one field (ex. a collection of 40 names). Here I have a collection (an array in fact) of a structure.
How do I setup the databinding?
As you can see, I'm new to this and probably would most benefit from a reference to an article. I've found articles covering collections of 1 field, but no examples covering binding to an array of structures. Also, my intitial research indicates c) can't be easily done, if you demand that the column is big enough for all the data in that column, not just the visible data.
Thanks, dave
© Stack Overflow or respective owner