OPunktSchmidt
OPunktSchmidt

Reputation: 721

Xamarin.Forms: Press back button from code

Is there a way in Xamarin.Forms to press the back button from code? I tried to call OnBackButtonPressed and SendBackButtonPressed but this does not work. The OnBackButtonPressed Event is called but the back action does not perform.

Call OnBackButtonPressed:

if (_currentQuestionnaireGroup != null)
   await RefreshDataAsync();
else
{
   App.QuestionnaireOverviewPage.IsDirty = true;
   this.OnBackButtonPressed();
}

Event:

protected override bool OnBackButtonPressed()
{
    if (_questionnaireHandler != null)
        App.QuestionnaireOverviewPage.IsDirty = true;

    return true;
}

Upvotes: 3

Views: 3875

Answers (1)

Diego Rafael Souza
Diego Rafael Souza

Reputation: 5313

Sorry for the poor english

In your Event, change return true; for return base.OnBackButtonPressed();.

When you return true, the action 'back' is canceled at device.

Upvotes: -1

Related Questions