Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 582305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:40:21+00:00 2026-05-13T14:40:21+00:00

I was planning to add support for the Back and Forward buttons, found on

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T14:40:22+00:00Added an answer on May 13, 2026 at 2:40 pm

    The buttons you refer to are handled as MediaCommands, NavigationCommands, ApplicationCommands, EditingCommands or ComponentCommands in WPF – you’ll need to add a CommandBinding for each of the buttons you want to intercept, for example:-

    <Window.CommandBindings>
    <CommandBinding Command="MediaCommands.PreviousTrack" 
                    Executed="PreviousTrackCommandBinding_Executed"/>
    <CommandBinding Command="MediaCommands.NextTrack"             
                    Executed="NextTrackCommandBinding_Executed"/>
    

    And add relevant events in code behind:-

    private void PreviousTrackCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
    {
        MessageBox.Show("Previous track");
    }
    private void NextTrackCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
    {
        MessageBox.Show("Next track");
    }
    

    I would say in your case it’s probably NavigationCommands.BrowseForward and NavigationCommands.BrowseBack. Check out… http://msdn.microsoft.com/en-us/library/system.windows.input.navigationcommands.aspx and http://msdn.microsoft.com/en-us/library/system.windows.input.navigationcommands_members.aspx

    Check out my blog post for more info and more code samples.

    http://richardhopton.blogspot.com/2009/08/responding-to-mediapresentation-buttons.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm planning to add XML support to application, but I'm not familiar with XML
I am planning to add a feature to an existing Android App. Because I
I'm planning to add openid support for a web application I'm building. I can't
Im researching about how to integrate full script support inside my app but have
Something like Click here to get started or whatnot. I am planning to add
Im planning to create an Alert view with three buttons, my problem is I
Iam planning to create an app, and not to publish it at the google
I'm planning on doing more coding from home but in order to do so,
I was planning to use url routing for a Web Forms application. But, after
I'm working on php, mysql on a project I'm planning to add a multilanguage

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.