Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
380
Accept value in XamMultiColumnComboEditor when user clicks off cell
posted

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://ko.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);
}
}
}