views:

154

answers:

2

I am writing an app in C# 3.5 in WPF. I want to programmatically add a DataGridComboBoxColumn in C# to a WPF toolkit DataGrid. The problem is that the control itself seems to not exist because I am missing either a directive or an assembly. I thought that System.Windows.Controls and by adding a reference to the WPFToolkit would handle this but it seems to not be... Am I missing something?

What I find odd is that in XAML there is no problem at all to create a DataGridComboBoxColumn...

Here is an example of what I am trying to accomplish:

SomeDataGrid.Columns.Add(new DataGridComboBoxColumn()
{
    Header="ColumnHeader", 
    //...
});

*Edit: By understanding a bit more my problem... I want to know also how you can do the equivalent XAML in C#:

<Window xmlns:WPFToolkit="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit">
</Window>
+1  A: 

Assembly WpfToolkit, namespace: Microsoft.Windows.Controls.

siz
I added a reference to WpfToolkit and I am using Microsoft.Windows.Controls, but still the DataGridComboBoxColumn is not identified by the interpreter and compiler... Am I doing something wrong?
Partial
Or perhaps I forgot to do something?
Partial
You might have forgotten to include something. :) I just popped open a WPF project in 2008 and could reference the type from Assembly WpfToolkit.
siz
OMG this is really stupid! I am so tired that I did not noticed that it was Microsoft.Windows.Controls instead of System.Windows.Controls!
Partial
EPIC FAIL on my part :(
Partial
A: 

In VS 2005 the following show in the example on page 300 of "Programming Microsoft Windows Forms - Charles Petzold - Microsoft Press"

using System;

using System.Drawing;

using System.Windows.Forms;

Edwin

Edwin Smith