WPF Toolkit Datagrid

The WPF Toolkit (WPF Toolkit – February 2010 Release 3.5) Yes 2010! contains the DataGrid with the Enter/Intro Key Exception and the 4.0 too (no source code). If you want to avoid the explanation, you can download my release:  WPFToolkit Datagrid solved (ren .doc to .dll)

When you press keydown, in several places the columnindex and the displayindex is setted to -1. Exploding. So the way I worked it around is keeping the displayindex on the way and setting it at the end. The changes in Datagrid.cs are:

Line 1638

// Use the row to scroll cell into view.
if (row != null)
int columnIndex = column.DisplayIndex;


Line 5517

DataGridColumn column = currentCellContainer.Column;
Int32 idx = column.DisplayIndex;

Line 5531

object rowItem = Items[index];
column.DisplayIndex = idx;
ScrollIntoView(rowItem, column);

And that is all, problem solved. Now you can add the datagrid to the MVVM WPF Example and works like a charm (IEditableObject working behind).

Apart here I show you how to implement the displayattribute to a binded datagrid:

this.dataGrid1.AutoGeneratingColumn += (s, e) =>
object[] dispatt = this.dataGrid1.Items.CurrentItem.GetType().
GetProperty(e.PropertyName).GetCustomAttributes(typeof(DisplayAttribute), false);
if (dispatt.Length > 0)
e.Cancel = !(dispatt[0] as DisplayAttribute).AutoGenerateField;


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s