Interpret enter as tab WPF

Arsen Mkrtchyan picture Arsen Mkrtchyan · May 16, 2009 · Viewed 14.7k times · Source

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!

Answer

Matt Hamilton picture Matt Hamilton · May 16, 2009

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>