wpfkeyboard-input

Interpret enter as tab WPF


I want to interpret Enter key as Tab key in whole my WPF application, that is, everywhere in my application when user press Enter I want to focus the next focusable control,except when button is focused. Is there any way to do that in application life circle? Can anyone give me an example?
Thanks a lot!


Solution

  • You can use my EnterKeyTraversal attached property code if you like. Add it to the top-level container on a WPF window and everything inside will treat enter as tab:

    <StackPanel my:EnterKeyTraversal.IsEnabled="True">
        ...
    </StackPanel>