0
votes

Here the default backKey button when a page is created:

The problem:

How to override this ? I want to check something before this backKey canGoBack !



 <Button Content="Button" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}" HorizontalAlignment="Left" 
Margin="16,15,0,0" VerticalAlignment="Top" Height="55"/>


---- Update : in LayoutAwarePage.cs


protected virtual void GoBack(object sender, RoutedEventArgs e)
        {
            // Use the navigation frame to return to the previous page
            if (this.Frame != null && this.Frame.CanGoBack) this.Frame.GoBack();
        }

1
Is it for Windows Phone 8 or Windows 8 ?Farhan Ghumra
For Windows 8, sorry for the wrong tag used.MilkBottle

1 Answers

0
votes

UPDATE 1

protected override void GoBack(object sender, RoutedEventArgs e)
{
    base.GoBack(sender, e);
    //Your logic goes here
}

I think you are using LayoutAwarePage class. It has implementation of GoBack event. You can edit the implementation. LayoutAwarePage.cs will be in common folder of project.