---
title: "How can use popup and how can I show and hide it in wpf?"  
description: "How can use popup and how can I show and hide it in wpf?"  
author: "Madam Walker"  
published: 2013-08-09  
updated: 2013-08-10  
canonical: https://www.mindstick.com/forum/1362/how-can-use-popup-and-how-can-i-show-and-hide-it-in-wpf  
category: "wpf"  
tags: ["wpf"]  
reading_time: 2 minutes  

---

# How can use popup and how can I show and hide it in wpf?

Hi [Mindstick](https://yourviews.mindstick.com/view/84668/how-mindstick-is-used-for-marketing-purposes)!

How can use [popup](https://www.mindstick.com/blog/11734/how-to-create-advanced-popup-or-banners-with-news-images-discounts-in-magento2) and how can I show and hide it in [wpf](https://www.mindstick.com/forum/304/wpf)?

thanks in [Advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)

## Replies

### Reply by Pravesh Singh

Hello!

##### Xaml Code:-

Below I write the code which is show a popup and automatic hide after one second in wpf :-

```
<Window x:Class="WpfApplication1.MainWindow"        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"        Title="MainWindow" Height="350" Width="525">    <Grid>         <Popup Name="popup1" PopupAnimation="Slide"  HorizontalOffset="200" VerticalOffset="-20" Height="60" VerticalAlignment="Bottom" Margin="0,0,277,128" HorizontalAlignment="Right" Width="162" Opacity="70" OpacityMask="#FF0A0808" OverridesDefaultStyle="True" StaysOpen="False" AllowsTransparency="True">                <StackPanel>                <StackPanel.Background>                    <ImageBrush ImageSource="/WpfApplication1;component/Images/Picture2.png" />                </StackPanel.Background>                <StackPanel Height="30" Background="Transparent" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Opacity="70" OpacityMask="#FFE8D3D3">                        <Label Name="lblClose" Content="X" HorizontalAlignment="Right" Foreground="White" FontWeight="SemiBold" FontSize="15" MouseRightButtonUp="lblClose_MouseRightButtonUp" ></Label>                    </StackPanel>                    <StackPanel Background="Transparent" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Opacity="70" OpacityMask="#FFE8D3D3">                        <Label Content="Follwoing" Margin="45,-20,20,20"  Foreground="White" FontWeight="SemiBold" FontSize="15"></Label>                     </StackPanel>                </StackPanel>        </Popup>         <Button Content="Button" Height="23" HorizontalAlignment="Left"  Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" Margin="75,33,0,0" BorderBrush="{x:Null}">            <Button.Background>                <ImageBrush ImageSource="/WpfApplication1;component/Images/Picture2.png" />            </Button.Background>        </Button>        <Label Content="Label" Height="31" HorizontalAlignment="Right"  Name="label1" VerticalAlignment="Bottom" HorizontalContentAlignment="Right" Margin="0,0,129,59"/>    </Grid></Window>
```

## Cs file

```
namespace WpfApplication1{    /// <summary>    /// Interaction logic for MainWindow.xaml    /// </summary>    public partial class MainWindow : Window    {        public MainWindow()        {            InitializeComponent();        }         System.Windows.Threading.DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer();        private void button1_Click(object sender, RoutedEventArgs e)        {             timer.Interval = new TimeSpan(0, 0, 1);            timer.Tick += new EventHandler(tickTime);            timer.Start();            popup1.Margin = new Thickness(-50, -100, 0, 0);            popup1.PlacementTarget = label1;                     popup1.IsOpen = true;        }        private void tickTime(object sender, EventArgs e)        {            if (timer.Interval.Seconds == 1)            {                popup1.IsOpen = false;                timer.Stop();            }        }        private void lblClose_MouseRightButtonUp(object sender, MouseButtonEventArgs e)        {            popup1.IsOpen = false;        }    }}
```


---

Original Source: https://www.mindstick.com/forum/1362/how-can-use-popup-and-how-can-i-show-and-hide-it-in-wpf

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
