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 ...
Hello,
Were you able to resolve your issue?
Sincerely,
Valerie
Developer Support Engineer
Infragistics
www.infragistics.com/support
To me there is nothing wrong with creating a derived ValueEditor that is specifically designed to host a xamMultiColumnComboEditor. Alternatively you could modify the XamControlHostEditor such that it exposes a EditModeExitingCommand property (of type ICommand) and have it invoke that command when its OnEditModeEnding is invoked. You could either have a EditorModeExitingCommandParameter property to determine the parameter or just assume it should provide the ValueEditor and pass itself along as the parameter for the command. This would keep the XamControlHostEditor generic.
You could then create a command that enumerates the visual tree of the editor looking for a XamMultiColumnComboEditor and closes its dropdown. You would modify the EditorStyle that has the XamMultiColumnComboEditor in it and add a setter that sets the new command property to your command that closes the dropdown.