messgaePrompt.Hide() not working

Aug 29, 2013 at 11:47 AM
I am displaying a MessagePrompt, but can't get the prompt to go away when I am done.

Here is my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using Coding4Fun.Toolkit.Controls;

namespace EasySchedule
{
    public  partial class LicenseMessage : UserControl
    {

        public static boundString profileMsgTextBoxText = new boundString();
        static MessagePrompt messagePrompt = new MessagePrompt { };

        
        public LicenseMessage()
        {
            InitializeComponent();
        }

        private void upgradeButton_Click(object sender, RoutedEventArgs e)
        {
            // Do stuff
            messagePrompt.Hide();
        }

        private void trialButton_Click(object sender, RoutedEventArgs e)
        {
            // Do stuff
            messagePrompt.Hide();
        }

        private void laterButton_Click(object sender, RoutedEventArgs e)
        {
            // Do stuff
            messagePrompt.Hide();
        }

        public static void Show(string titleMsg, string bodyMsg, bool isTrial)
        {
            profileMsgTextBoxText.Name = titleMsg;

            MessagePrompt messagePrompt = new MessagePrompt { };
            LicenseMessage newMsg = new LicenseMessage();
            messagePrompt.Body = newMsg;
            messagePrompt.ActionPopUpButtons.Clear();
            newMsg.titleText.Text = titleMsg;
            newMsg.messageText.Text = bodyMsg;
            if (isTrial)
                newMsg.trialButton.Visibility = Visibility.Visible;
            else
                newMsg.trialButton.Visibility = Visibility.Collapsed;

            messagePrompt.Show();
        }
        
    }
}
And here is the XAML:
<UserControl x:Class="EasySchedule.LicenseMessage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    d:DesignHeight="480" d:DesignWidth="480">

    <Grid x:Name="LayoutRoot" Background="{StaticResource PhoneChromeBrush}">
        <StackPanel>
            <TextBlock Name="titleText" Text="Test123" FontSize="{StaticResource PhoneFontSizeLarge}" Margin="0,0,0,32" />
            <TextBlock Name="messageText" Text="Rename Profile:" FontSize="{StaticResource PhoneFontSizeMedium}" Margin="0,0,0,32" />
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                <Button Name="upgradeButton" Content="Upgrade" Click="upgradeButton_Click" HorizontalAlignment="Center"/>
                <Button Name="trialButton" Content="Trial" Click="trialButton_Click" Visibility="Collapsed"/>
                <Button Name="laterButton" Content="Later" Click="laterButton_Click"/>
            </StackPanel>
        </StackPanel>
    </Grid>
</UserControl>
The control is called like this:
                    LicenseMessage licenseMessage = new LicenseMessage();
                    LicenseMessage.Show("Trial Message", "This is a test of my new messaging system.\n\nThis is only a test", false);
When I click on the buttons, their Click event is fired, but the messagePrompt.Hide() call does not make the MessagePrompt go away.

Any idea whet I am doing wrong?
Aug 29, 2013 at 11:54 AM
Never mind. I just figured it out.

I had messagePrompt defined twice. I deleted the definition that was in the Show() method and all is well.
Coordinator
Aug 29, 2013 at 6:31 PM
I suggest doing a class wide private with an underscore ala _msgPrompt to prevent that issue