We have extended ValueEditor to create a Control Host class which we use to host a class derived from XamMultiColumnComboEditor in XamDataGrid. We used the information here:
http://es.infragistics.com/community/blogs/andrew_smith/archive/2009/03/27/hosting-wpf-controls-in-a-xamdatagrid-cell.aspx
to aid us in this process. We would like to be able to click off the cell and have the cell accept whatever option is highlighted in the dropdown before the cell loses focus. I was able to get this working for tab, but have been unable to devise a way to do this for a click off. Any ideas on how I can do this? This is the code that we used to get it working for tab:
protected override void OnKeyDown(KeyEventArgs e)
{ if (e.Key == Key.Tab) { e.Handled = true; IsDropDownOpen = false; CommitChangesAndMoveToNextCell(); } else { base.OnKeyDown(e); }}
private void CommitChangesAndMoveToNextCell(){ var editor = Infragistics.Windows.Utilities.GetAncestorFromType(this, typeof(XamControlHostEditor), true) as XamControlHostEditor; if (editor != null) { editor.EndEditMode(true, true); var cvp = Infragistics.Windows.Utilities.GetAncestorFromType(editor, typeof(CellValuePresenter), true) as CellValuePresenter; if (cvp != null) { cvp.DataPresenter.ExecuteCommand(DataPresenterCommands.EndEditModeAndAcceptChanges); cvp.DataPresenter.ExecuteCommand(DataPresenterCommands.CellNextByTab); } }}
Have you tried with overriding OnEditModeEnding on ValueEditor and close the dropdown before calling the base?
Thanks,
George
That might work, but the ValueEditor is a generic WPF control container. It does not know what it contains - in this case it is a XamMultiColumnComboEditor, but not in all cases. I don't want to make it specific to XamMultiColumnComboEditor, and XamMultiColumnComboEditor doesn't have an OnEditModeEnding ...