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!
We are evaluating grid controls for an engineering application. We are using WPF for GUI. I started looking at the Xceed grid today. It seems we cannot select multiple cells like we do in Excel. It seems to select a row. Ourt users are used to using grid controls like a spreadsheet control.
Is it true that the Xceed grid control is more suited for Database type of applications rather than something that requires spreadsheet-like functionality?
Thanks
Hi Pankaj, no, I do not believe that is true. In the application in which I used Xceed Grid for WPF, the grid was set up to allow selection and navigation cell by cell and by entire row, just like Excel. If you are referring only to whether it has the feature of selecting a random assortment of individual cells, as in Excel, I am not sure that it can do that today. You should post a question about that in Xceed’s WPF forum or contact them.
Keep in mind that all of the WPF grid controls out there today are quite immature, all things considered, so none of them are comparable to the feature sets available for Windows Forms grid controls. That’s the price we pay today to use WPF. Xceed’s WPF grid just happens to work very well overall and have a more robust feature set compared to other WPF grid offerings today.
Thanks for reading! — Tom
>>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.
That’s recently changed. We’re working on that right now, and it is scheduled for the v2.1 release this summer.
>>Pankaj wrote: Keep in mind that all of the WPF grid controls out there today are quite immatureall things considered, so none of them are comparable to the feature sets available for Windows Forms grid controls.
Since you wrote that comment, I think that’s not quite so true anymore. Xceed DataGrid for WPF now has had 5 major version updates, another 5-6 minor releases, and as of v2.0, is, for most purposes, at feature-parity with many Windows Forms grids (such as Xceed’s own). The product is approaching 1.5 years on the market, as well. v2.1 coming out this summer will have equal (and in some ways surpass) the best of the Windows Forms grids.
But if you take the market in general, you’re right, though. A few vendors have not even released their WPF Grids yet, which means that when they do, even if they have lots of features and good performance, they will be too green to rely on when compared to Xceed’s. A WPF DataGrid is a very complex control. Xceed has (at the moment) about 15 months worth of field use by customers (lots!), corrections, improvements, and bug fixes. The forums have nearly 5000 posts, that’s 5 times more than the nearest competitor, there’s a lot of momentum.
Thanks to Thomas for the great comment on the grid!
I am actually quite familiar with Infragistics, and their WPF stuff is all developed in eastern Europe, which is probably the reason no one responds. That’s the price of outsourcing.