Search code examples
c#windows-phone-7

Programmatically closing a WP7 Coding4Fun toolkit MessagePrompt Control


I am using the MessagePrompt control from the Coding4Fun toolkit to show a "Rate and Review" dialog in my app.

I have replaced the default buttons with custom buttons as well as clearing the existing buttons (to get rid of the ticks and crosses) but cannot figure out which method to call to close the prompt.

This is the code I am using, Id like to close the prompt in the click method of the cancel button

var messagePrompt = new MessagePrompt
{
    Title = "Rate and Review",
    IsAppBarVisible = false,
    Body = new TextBlock
    {
        Text = "PLS REVIEW MY APP K THNX",
        TextWrapping = TextWrapping.Wrap
    }
};

var rateButton = new Button() { Content = "Rate and Review" };
rateButton.Click += (sender, e) =>
{
    var m = new MarketplaceDetailTask
    {
        ContentIdentifier = PhoneState.AppID,
        ContentType = MarketplaceContentType.Applications
    };

    m.Show();
};

var cancelButton = new Button() { Content = "Dismiss" };
cancelButton.Click += (sender, e) =>
{
    //todo close messagePrompt here
};

messagePrompt.ActionPopUpButtons.Clear();
messagePrompt.ActionPopUpButtons.Add(rateButton);
messagePrompt.ActionPopUpButtons.Add(cancelButton);

messagePrompt.Show();

Solution

  • The newest check in of the toolkit exposes the Hide() method to solve this.

    cancelButton.Click += (sender, e) =>
    {
        messagePrompt.Hide();
    };