Skip to content

Instantly share code, notes, and snippets.

@ChrisWay
Created November 6, 2013 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChrisWay/7333250 to your computer and use it in GitHub Desktop.
Save ChrisWay/7333250 to your computer and use it in GitHub Desktop.
Fix for XamDataGrid Issue GetAncestor just walks the visual tree looking for Parent of the given type.
public void KeyDownHandler(object sender, KeyEventArgs e)
{
var cb = (ComboBox)sender;
if (e.Key != Key.Tab || !cb.IsDropDownOpen)
return;
var item = (ComboBoxItem)FocusManager.GetFocusedElement(FocusManager.GetFocusScope(cb));
cb.SelectedItem = item.Content;
cb.IsDropDownOpen = false;
cb.GetAncestor<XamDataGrid>().ExecuteCommand(DataPresenterCommands.CellNextByTab);
e.Handled = true;
}
<Style TargetType="{x:Type igEditors:XamComboEditor}" x:Key="GridComboFix">
<Setter Property="ComboBoxStyle">
<Setter.Value>
<Style TargetType="ComboBox">
<EventSetter Event="KeyDown" Handler="KeyDownHandler"></EventSetter>
</Style>
</Setter.Value>
</Setter>
</Style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment