How to dismiss a popup on a xamarin form?

How to dismiss a popup on a xamarin form? I am showing an alert popup by calling

var actionButton2 = new Button { Text = "ActionSheet" };
actionButton2.Clicked += async (sender, e) => {
    var action = await DisplayActionSheet ("ActionSheet: Save Photo?", "Cancel", "Delete", "Photo Roll", "Email");
    Debug.WriteLine("Action: " + action); // writes the selected button label to the console
};

      

Now how can I opt out of it programmatically?

+3


source to share


3 answers


You can not.

The action sheet is for user interaction, not programmatic interaction. The whole idea of ​​the action sheet is that the flow of the program depends on user input at this point and cannot continue without that input.



So the user has to do something with the action sheet or reject it by pressing the hardware return button.

+1


source


There is a possibility. See the latest answer here: https://forums.xamarin.com/discussion/94185/is-there-a-way-to-dismiss-display-alerts-action-sheets-when-the-app-is-entering-background



This worked for me.

0


source


To give a more complex answer.

The Xamarin.Forms method does DisplayActionSheet

n't support dismiss, so basically you can't. However, native operating systems have their own methods that are mapped to DisplayActionSheet

. On iOS it is not possible to disable such a warning, but on Android this is: How to programmatically remove AlertDialog . So if you want to close the dialog on Android it is possible, but you will need to use a native method to call it.

0


source







All Articles