Question Downloaded WPFToolKit and DataGrid methods not available. What am I doing wrong?

vbsemipro

New member
Joined
Nov 9, 2008
Messages
4
Location
Birmingham
Programming Experience
10+
Specifically...All the examples that I see for binding a source to a DataGrid show "DataGrid1.SetDataBinding(dataset, table)". However I get an error that 'SetDataBinding' is not a member of Microsoft.Windows.Controls.DataGrid. If Someone could help me correct my 'stupid' error, I would greatly appreciate you helping me to get started with WPF. I'm a newbie with WPF, and am just trying to learn.

Bill
 
First up, if you're using .NET 3.5 then you don't need the WPF Toolkit. The DataGrid class was not part of the original WPF release and was provided later as part of the add-on Toolkit. When .NET 3.5 was released, the WPF DataGrid was included as standard.

As for the examples you've been reading, they are all irrelevant I'm afraid. SetDataBinding is a member of the Windows Forms DataGrid, not the WPF DataGrid. You should be binding a WPF DataGrid in XAML, just as you should bind all your other controls in XAML.
 
Without the WPFToolkit I don't even show the DataGrid in the Toolbox. I only have the Grid, and I am getting the feeling that they are not the same? In my research, it seems that the DataGrid was not originally available in WPF, but then released by means of the WPFTookKit, and I do use Framework 3.5 sp1, and Visual Studio 2008. Am I way out in left field.
 
I just had a quick look in the library, it is true DataGrid was added to WPF from .Net 4

Hmmm... I couldn't remember myself so I checked MSDN and the DataGrid has doco going back to .NET 3.5. I'm not sure why that doco would be there if the control didn't exist but there you go. Sorry about the misdirection.
 
This lists from .Net 4: DataGrid Class (System.Windows.Controls)
Where did you see .Net 3.5 ?

On the right, where it says:
This page is specific to
Microsoft Visual Studio 2010/.NET Framework 4

Other versions are also available for the following:

Microsoft Visual Studio 2008/.NET Framework 3.5
Microsoft Silverlight
Microsoft Visual Studio 2012/.NET Framework 4.5
Now I notice that, even if you select the .NET 3.5 link there, at the bottom of the page it leads to it says that the documentation applies only to .NET 4.0 and 4.0 Client Profile. That's probably the spot I should have looked at in the first place. :topsy_turvy:
 
I can only see a 'Other Versions' dropdown on the top right, that lists Silverlight and .Net 4.5. I'm viewing the US-English version of MSDN though.
 
Back
Top