This is an example of the behavior I have created:
public class EnterKeyClosesPopupBehavior : Behavior<FilteringDropDown>
{
protected override void OnAttached()
{
AssociatedObject.KeyDown += AssociatedObject_KeyDown;
}
protected override void OnDetaching()
{
base.OnDetaching();
AssociatedObject.KeyDown -= AssociatedObject_KeyDown;
}
private void AssociatedObject_KeyDown(object sender, KeyEventArgs e)
{
if(e.Key == Key.Enter)
{
AssociatedObject.IsDropDownOpen = false;
}
}
}
and then in GridViewHeaderCellTemplate you need to attach this behavior to the filtering popup, something like this:
<grid:FilteringDropDown x:Name="PART_DistinctFilterControl" Grid.Column="1" Visibility="{TemplateBinding FilteringUIVisibility}" Margin="0,0,-2,0">
<i:Interaction.Behaviors>
<EnterKeyClosesPopupBehavior />
</i:Interaction.Behaviors>
</grid:FilteringDropDown>
hope you find this helpful.