Our team is currently implementing some UI/UX improvements to standardize how a user saves/cancels any changes made while editing data in our app; and I've got everything working except this last issue on Android. I have a content page that displays account information (Name, address, account #, etc) using entry controls which by default have their IsReadOnly bindings set to true. However; if a user taps an 'edit' button up in the toolbar, the user is now in 'Edit Mode'; all of the entry controls IsReadOnly bindings are set to false and the user if free to make changes.
The problem: To avoid ambiguity in my save/cancel pattern, I want to dynamically remove the back button from the toolbar if the user is in 'Edit Mode', and then add it back once the user saves changes. This works perfectly fine on iOS and UWP. Android only seems to allow setting the back button ONE time at page construction using something like this:
NavigationPage.SetHasBackButton(this, false);
Is there a fix/workaround on Android for hiding the back button on a content page that has already been constructed?
Currently my workaround on Android is to intercept the back button press on Android and show the user a dialog warning them they are about to lose their changes and giving them the ability to save first.
CodePudding user response:
Do you mean the up button (left arrow) If so you could use
toolbar.NavigationIcon = null;
CodePudding user response:
You want to Hide and Show the BackButton with ButtonClicked.
private void Button_Clicked(object sender, EventArgs e)
{
NavigationPage.SetHasBackButton(this, false);
}
private void Button_Clicked_1(object sender, EventArgs e)
{
NavigationPage.SetHasBackButton(this, true);
}