MicrosoftDocs / windows-dev-docs

Conceptual and overview content for developing Windows apps
Creative Commons Attribution 4.0 International
699 stars 1.21k forks source link

Override Keyboard Navigation #1407

Open arqlz opened 5 years ago

arqlz commented 5 years ago

How to override Keyboard Navigation so none action is done when UP, DOWN, LEFT and RIGHT keys are pressed?


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

ghost commented 5 years ago

In the treeView create event PreviewKeyDown="TreeView_PreviewKeyDown"

    private void TreeView_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
    {
        e.Handled = true;
    }

This will do the trick.

arqlz commented 5 years ago

No, if you do that none other component will receive the keypress event... I need to handle it on a sub element.

example

 Treeview
        TreeViewItem
                TextBox <-- here i want to handle the event