Listview with auto generation of column + enable disable columns

hello guys,

Back in the days of winforms in .Net 2.0 and 1.1, one of the controls that I really loved was the datagridview aka datagrid.

One of the most powerful features of the data grid was that if you wanted to; you could just specify an ItemsSource and the datagridview would create all the column for you. The data grid would do this by looking at the object properties by reflection. Unfortunatly WPF does not have such a control, yet WPF is flexible enough to let you do something similar by using the listview.

I have developed a similar control to the DataGridView that supports auto generation of columns by looking at the properties of the object that you push from the ItemsSource…

Auto generation of columns sometimes is to implicit. Sometimes you would like to order your column, exclude a property from showing in the listview or even display the header text differently than the property name… My solution was to create a custom attribute that can specify additional information for the datagridview control. This is very easy to use but yes, you are coupling the business object with UI specific information, so please if anyone has some feedback/ideas how I can improve this let me know…

Another interesting feature that this control supports is the concept of having Collections as propeties. The question here is “How do I represent the data of my collection in the listview?”.
Well from experiance I can say that usually you would need only the count of the collection or maybe the last value of the collection (maybe even something else that is truly custom), so what i have introduced to the control is the CollectionBehaviour. This is an enum that currently supports Count and LastValue yet eventually I m going to refactor the control to support even custom behaviours. I implement this by using the Stratagy design pattern where I have a ICollectionNotificationStrategy interface and 2 different class that implement a different strategy one for the count and one for the last value. In this way the collection behaviour is scalable enough to eventually support custom behaviours…(I will introduce this feature next week)

This control also supports enable and disable of column…. Yes, as you know the WPF listview does not dirrectly support this feature, so I decided to add it in the datagridview….

The Future…

I am planning to support sorting and paging. And maybe even sorting on property notifictaions… This will not be easy since sorting on property notifications implies a performance hit… but yes, I will try to do it…

enough talking… guys feel free to download the sorce code + demo of this control here

please send feed back….