How to navigate back by clicking a button?

Aug 28, 2014 at 2:47 PM

I would like to ask, how can I navigate back in my ModernUI WPF application by clicking a simple button, not the "back" button that is in upper left corner.

I have a ModernWindow with EmptyWindow Style, which does not have the "back" button so I want a kind of replacement for that and I can't find any solution for this :-/

Any help will be appreciated. Thanks!
Aug 28, 2014 at 6:39 PM
You can add the back button to your window content. What the back button should do, when clicked, is entirely up to you.
Aug 28, 2014 at 7:05 PM
Yes, I know but how do I bind the "back" command to that button? Basically I want the same functionality as the default "back" button has.
Aug 28, 2014 at 7:46 PM
Edited Aug 28, 2014 at 7:47 PM
Check the back button style as defined in the default ModernWindow style (Themes/ModernWindow.xaml in the source). The NavigationCommands.BrowseBack command is used for navigation with the command target set to a ModernFrame instance.
Aug 28, 2014 at 9:30 PM
I tried what you advised me but there is one problem. My new Back Button somehow does not "share the navigation history" (or something like that I think) with the original Back Button even though it is still the same instance of ModernWindow. I think it is probably because the Content is not the same and that's why it doesn't work.
Am I right or is it something else? And is there a way how to fix this problem?

Thanks ;-)
Sep 2, 2014 at 9:05 AM
The default BackButton does operate on the main ModernFrame instance. The EmptyWindow style does not contain this ModernFrame instance, and therefor the back button won't work. You'll need to bring in your own ModernFrame instance, or use the default ModernWindow style, instead of EmptyWindow.
Sep 2, 2014 at 9:14 AM
Could you please give me an advice about how to bring in my own ModernFrame instance? Because I am not creating new window, I am just changing the Content of the default one.
Dec 29, 2014 at 10:45 PM
You could use the NavigationCommands static class. For example:
public void CancelExecuted(object o)
      NavigationCommands.BrowseBack.Execute(null, null);