Hello,
After upgrading to the latest version (2009.1.312.35) of the WPF Grid View my custom grid editor controls have stopped working, though they worked fine with the previous version (2008.3.1217.35). I used ideas from a forum post to create a grid editor control that allows users to type in any value they want in the combo box so they're not restricted to just the values in the list.
Now whenever I double click to edit a cell using my custom editor control, the value gets cleared and the editor does not show up. I have to click a third time to get the editor to appear and once it does it is blank because the value got cleared. When I debug I can see that the DataContext is always null whereas with the previous version the DataContext was always populated with the object the row was bound to.
I can reproduce this behaviour in the ForeignKey sample project from the forum post that I linked to earlier by making the following changes.
Changed this:
to this:
Notice how when you double click on a cell in the PersonType column, the value gets cleared. Once you click a third time the editor will appear.
(Please note that to get this sample project to work with the latest version of the grid I also had to change the editor settings properties to be regular properties because EditorSettings seems to no longer be a dependency object.)
I hope someone can help me with this problem.
Thanks,
Joel
After upgrading to the latest version (2009.1.312.35) of the WPF Grid View my custom grid editor controls have stopped working, though they worked fine with the previous version (2008.3.1217.35). I used ideas from a forum post to create a grid editor control that allows users to type in any value they want in the combo box so they're not restricted to just the values in the list.
Now whenever I double click to edit a cell using my custom editor control, the value gets cleared and the editor does not show up. I have to click a third time to get the editor to appear and once it does it is blank because the value got cleared. When I debug I can see that the DataContext is always null whereas with the previous version the DataContext was always populated with the object the row was bound to.
I can reproduce this behaviour in the ForeignKey sample project from the forum post that I linked to earlier by making the following changes.
Changed this:
comboBoxEditor.GotFocus += ((sender, e) => |
{ |
PersonType personType = (PersonType)((Field)this.DataContext).Value; |
comboBoxEditor.SelectedItem = (from PersonType item in comboBoxEditor.Items |
where item.PersonTypeID == personType.PersonTypeID |
select item).FirstOrDefault(); |
}); |
to this:
comboBoxEditor.GotFocus += ((sender, e) => |
{ |
var person = DataContext as Person; |
if (person != null && person.PersonType != null) |
{ |
comboBoxEditor.SelectedItem = (from PersonType item in comboBoxEditor.Items |
where item.PersonTypeID == person.PersonType.PersonTypeID |
select item).FirstOrDefault(); |
} |
}); |
Notice how when you double click on a cell in the PersonType column, the value gets cleared. Once you click a third time the editor will appear.
(Please note that to get this sample project to work with the latest version of the grid I also had to change the editor settings properties to be regular properties because EditorSettings seems to no longer be a dependency object.)
I hope someone can help me with this problem.
Thanks,
Joel