Reputation:
I am using Xamrin.forms PLC Project, So,I am trying to disable back button when Activity Indicator is Running then I will enable back button when Activity Indicator is finished. this is My Code:
protected override void OnAppearing()
{
activityIndicator.IsRunning = true;
activityIndicator.IsVisible = true;
//I need to disable back button here
activityIndicator.IsRunning = false;
activityIndicator.IsVisible = false;
//I need to enable back button here
}
Upvotes: 2
Views: 669
Reputation: 9723
You can use the static NavigationPage.SetHasBackButton
method (See here) to hide the back button of your page.
Furthermore you can override OnBackButtonPressed
protected override bool OnBackButtonPressed()
{
if(activityIndicator.IsRunning = true)
{
return true;
}
return false;
}
(see here) to prevent going back when the user presses the hardware back button.
Upvotes: 3