locked
AppBarButton Back Button not working?

    Question

  • I have the following button on my page:

     <AppBarButton Grid.Column="0" x:Name="backButton" Icon="Back" Margin="10,26,0,-1"
                          Command="{Binding NavigationHelper.GoBackCommand, ElementName=pageRoot}" 
                          IsEnabled="True"
                          Visibility="Visible"
                          Foreground="Green"
    
                          AutomationProperties.Name="Back"
                          AutomationProperties.AutomationId="BackButton"
                          AutomationProperties.ItemType="Navigation Button" Grid.Row="1" Grid.RowSpan="2" VerticalAlignment="Stretch"
                          />

    The button appears but clicking it does nothing. This was placed on the second of two pages in the application. I followed the instructions in NavigatonHelper.cs to get it wired up to my second page, but haven't done anything special in the first. What am I missing?

    I even tried tying the Click property to a custom function:

     public void ClickGoBack(object sender, RoutedEventArgs routedEventArgs) {
            this.Frame.Navigate(typeof(HubPage));
        }

    But this never even got hit when I clicked the button.

    Wednesday, May 28, 2014 3:22 AM

Answers

  • Look goto your Document outline and check your back button placed correctly or not .

    then type in your mainpage.xaml.cs

    public void ClickGoBack(object sender, RoutedEventArgs routedEventArgs) {
            this.Frame.Navigate(typeof(HubPage),null);
        }

    if it works fine ,. otherwise check the page you placed if it inside assets.then you have to write:\

    public void ClickGoBack(object sender, RoutedEventArgs routedEventArgs) { this.Frame.Navigate(typeof(Assets.HubPage),null); }

    nd delete the command in xaml because its binding the command of appbar button.

     (->Command<-="{Binding NavigationHelper.GoBackCommand, ElementName=pageRoot}") 
    delete this^
    Wednesday, May 28, 2014 5:20 AM
  • does your page also have the name pageRoot (<Page x:Name="pageRoot") and do you have a property NavigationHelper in the code behind of your page?

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Wednesday, May 28, 2014 6:09 AM

All replies

  • Look goto your Document outline and check your back button placed correctly or not .

    then type in your mainpage.xaml.cs

    public void ClickGoBack(object sender, RoutedEventArgs routedEventArgs) {
            this.Frame.Navigate(typeof(HubPage),null);
        }

    if it works fine ,. otherwise check the page you placed if it inside assets.then you have to write:\

    public void ClickGoBack(object sender, RoutedEventArgs routedEventArgs) { this.Frame.Navigate(typeof(Assets.HubPage),null); }

    nd delete the command in xaml because its binding the command of appbar button.

     (->Command<-="{Binding NavigationHelper.GoBackCommand, ElementName=pageRoot}") 
    delete this^
    Wednesday, May 28, 2014 5:20 AM
  • does your page also have the name pageRoot (<Page x:Name="pageRoot") and do you have a property NavigationHelper in the code behind of your page?

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Wednesday, May 28, 2014 6:09 AM