I was planning to add support for the Back and Forward buttons, found on many keyboards, to my WPF app, but I m struggling to get them to work.
I ve tried using a standard KeyBinding to BrowserBack and BrowserForward, no joy. I tested the code with the ESC key to make sure it was working in principal, and that key was fine.
Nextup I handled the KeyUp event, but the key that gets sent is "System", which is useless, and if I use KeyInterop.VirtualKeyFromKey I just get 0 returned.
I m starting to think that PInvoke/trapping real Window Messages are going to be the only option, but I d rather avoid that if anyone has any bright ideas?
Oh, and the keys themselves definately work, and my keyboard is plugged in ;-)
Update: They suggest to use SystemKey got me to a point that I can get it working with:
new KeyBinding(TestCommand, new KeyGesture(Key.Left, ModifierKeys.Alt));
And that seems to work for the keyboard button, but it doesn t work for the corresponding touch "flick" (which simulates next and back). Those flicks work fine in the browsers, but according to my KeyUp event all they re sending is "LeftAlt" and not much else!
** Update Again ** : Rich s comment got me to this:
this.CommandBindings.Add(new CommandBinding(NavigationCommands.BrowseBack, BrowseBack_Executed));
this.CommandBindings.Add(new CommandBinding(NavigationCommands.BrowseForward, BrowseForward_Executed));
Which seems to work a treat.. flicks too!