bhaku
bhaku

Reputation: 448

how to display a pop up message on clicking a button in windows phone 7

I am building an application in Windows Phone 7 where i have a button which when clicked i want to display a pop up message which again will contain 3 buttons. Can anyone please tell me how to display this pop up message which will contain 3 buttons.

Upvotes: 0

Views: 1138

Answers (2)

imthegiga
imthegiga

Reputation: 1126

You can achieve it in xaml. You can add a Popup tag and in between that tag, you may add a StackPanel which contains a text message and 3-4 buttons as you want. A snippet to that I found so far:

<Popup x:Name="my_popup_xaml" Grid.Row="2">
    <Border  BorderThickness="2" Margin="10" BorderBrush="{StaticResource PhoneAccentBrush}">
      <StackPanel Background="LightBlue">
        <Image Source="/Images/disclaimer.png" HorizontalAlignment="Center" Stretch="Fill" Margin="0,15,0,5"/>
        <TextBlock Text="Disclaimer" TextAlignment="Center" FontSize="40" Margin="10,0" />
        <TextBlock Text="This is a pop-up window to display disclaimer" FontSize="21" Margin="10,0" />                      
        <StackPanel Orientation="Horizontal" Margin="0,10">
          <Button x:Name="btn_continue"  Content="continue" Width="215" Click="btn_continue_Click"/>
          <Button x:Name="btn_cancel"    Content="cancel"   Width="215" Click="btn_cancel_Click"/>
        </StackPanel>
      </StackPanel>
    </Border>
</Popup>

You can add multiple buttons as per requirements because we are going to add them in a StackPanel.

well to make it work, you need to add Reference Microsoft.Phone.Controls in your project.

Pop up can be displayed through code, but I recommend to use xaml instead of code; its easy to implement!

To know more about it you can hit THIS LINK

To make it more advanced, like, to save the state of Pop up you can check THIS LINK

Thanks.

Upvotes: 1

aloisdg
aloisdg

Reputation: 23521

Perhaps a little outdated, but you can use WPAssets.

You can call the MessageBox like this :

    private void buttonAny_Click(object sender, RoutedEventArgs e)
    {
        NotificationTool.Show(
            "Custom",
            "Click on any of the buttons below.",
            new NotificationAction("Xxx", () => { }),
            new NotificationAction("Xxx", () => { }),
            new NotificationAction("Zzz", () => { }));
    }

Sample from the source of the project.

enter image description here

Upvotes: 0

Related Questions