Frage

In my app i display a MessagePrompt from the Coding4Fun toolkit, i display it like this:

            //Show Prompt
        var Prompt = new MessagePrompt
        {
            Title = "Delete Notes",
            Message = "Are you sure you want to remove all of your notes? This action is not reversible"
        };
        Prompt .IsCancelVisible = true;
        Prompt .Completed += deleteSubjectPrompt_Completed;
        Prompt .Show();

And i handle the click event like this:

        private void deleteSubjectPrompt_Completed(object sender, PopUpEventArgs<string, PopUpResult> e)
    {
        //Handle
    }

The code to run when the user presses the ok button in the prompt works, but when the user clicks the cancel button, the same code executes as "ok" code. What am i doing wrong here?

War es hilfreich?

Lösung

Within deleteSubjectPrompt_Completed you have to check e.PopUpResult.

Something like this:

switch (e.PopUpResult)
{
    case PopUpResult.Cancelled:
        break;
    case PopUpResult.NoResponse:
        break;
    case PopUpResult.Ok:
        break;
    case PopUpResult.UserDismissed:
        break;
    default:
        break;
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top