Solved via a different design:
Instead of waiting for the user to interact with the dialog, and blocking everything else, we instead provide an EventHandler
in our call to the static Show
method that fires when the user clicks a button:
public static void Show(string title,
string message,
Context context,
EventHandler handler,
ConfirmationAlertButton button) { ... }
We maintain a private reference to the passed in EventHandler
that gets triggered on the button click like so:
private static void OkClicked(object sender, DialogClickEventArgs e)
{
if (_handler != null)
{
_handler.Invoke(sender, e);
}
_instance.Dismiss();
_instance = null;
_handler = null;
}
Here is an example of what a call to Show
looks like from an Activity:
ConfirmationDialog.Show(@"Message title",
@"Message text",
this,
delegate
{
if (e.Result)
{
Finish();
}
else
{
Invalidate();
}
},
ConfirmationAlertButton.OK);
If anyone would like more information on using a static dialog in their Xamarin Android application, just let me know!