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
1405
Intercept delete keydown event
posted

Hy.

I am trying to build a XamComboEditor with autocomplete functionality. I was able to filter the data inside the XamComboEditor when typing letters (KeyDown event), but I don't know how to fill back the XamComboEditor when deleting the letters because the KeyDown event is not triggered. So the method that filters data it's not called.

The delete or backspace key are not intercepted by the KeyDown event?

Thanks for help.

Nico 

Parents
No Data
Reply
  • 9694
    Verified Answer
    posted

    You can intercept and remove the Backspace and Delete Key actions with the PreviewKeyDown event. Assign it to the editor or to the container element in order to kill all instances of this key event.

    private void OnPreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
    {
       
    if (e.Key.Equals(System.Windows.Input.Key.Delete)
                  || e.Key.Equals(System.Windows.Input.
    Key.Back))
        {
            e.Handled =
    true;
        }
    }

     

Children