Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 84751

Close Filter Popup on Enter Key

$
0
0

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.


Viewing all articles
Browse latest Browse all 84751

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>