As you may or may not know, Windows Presentation Foundation (WPF) does not ship with a data grid control. [I’ll pause while I wait for the cursing to die down…] First, I need to make an important distinction: there is a Grid control in WPF, but it is a layout control, not a data grid like Windows Forms’ DataGridView/DataGrid. The good news is that the usual array of third-party component vendors has jumped in to fill the gap. The bad news is that most are still at various stages of beta or 1.0 releases.
Update: For the sake of completeness, I should mention that Windows Forms controls can be hosted in WPF, and that’s another option to consider. Here, I’m talking about “pure” WPF controls.
The WPF data grid controls that I have discovered include:
- Syncfusion Essential Grid (supposedly arriving in March 2008)
- Infragistics xamDataGrid (currently in 1.x release)
- Xceed DataGrid for WPF (currently in 1.3 release)
For the last three months I’ve been working on a .NET 3.5 WPF-based business application (a rare animal these days, since most WPF samples and real-world apps are highly consumer-oriented). I’ve been using Visual Studio 2008 Beta2, and jumped over to the RTM the day it was available. The main purpose of this application is data editing, so I needed a solid data grid control. I started by checking out the options listed above.
My first approach was Infragistics xamDataGrid. They offer a free Express edition, so I started with that (and later purchased the product to obtain support). It went in pretty easily and visually looked nice. My data source is a collection of objects that implements IBindingList. If your collection class does not implement IBindingList, you will not be able to add new rows to the grid (this is also true with Xceed). I quickly discovered that xamDataGrid did not provide the out-of-box behaviors that one would expect when adding and canceling a new row. For instance, if you start a new row, enter some values, then hit Escape twice, my expectation is that the new row is canceled and removed (see Access, SQL Management Studio, etc.). I also had trouble getting the grid to bind to a column using a ComboBox instead of a string value. I had a collection of objects that represented all possible values of a field (CountriesCollection, for example), and was binding the ComboBox to a property of that same object type (binding CurrentCountry property, of type Country, for example).
The Infragistics support forum for xamDataGrid consisted of many people posting questions and rarely receiving answers. There were many threads ending with “Hello, is anyone from Infragistics listening?” Thinking that premier support would be great, we purchased the product. Quite frankly, I was disappointed with the “premier” support. I got responses that did not address my specific scenario (as explicitly described in the support request), and those that said “it’ll be fixed in a future hotfix.” Suffice it to say, I dumped xamDataGrid.
I highly recommend Xceed DataGrid for WPF. This is a solid product with good support. It has been out in real release, not beta, for a long time already, and it just works. It took a half day or so to drop it in and hook it up, figure out a few subtleties, and it was ready to go. I still had some questions, so we purchased this product too, and their support staff turned the questions around quickly with definitive answers. Xceed also offers a free, highly-capable version of DataGrid for WPF, so check it out. One thing to note if you are used to Windows Forms data grids: Xceed DataGrid for WPF does not support the IDataErrorInfo interface for bound object validation and automatic error display. They have that in their suggestions list but with no timeline.
Save yourself some time and hassle and go straight to Xceed DataGrid for WPF.
NOTE: I have no connection to Xceed whatsoever; I just hope this saves you some time since I learned the hard way!