SIGN UP MEMBER LOGIN:    
ARTICLE

Popup Window in WPF

Posted by Syed Shakeer Articles | WPF with C# January 19, 2011
This article shows you how to add controls, how to Open and Close the Popup Window.
Reader Level:

This article shows you how to add controls, how to Open and Close the Popup Window.

Popup: Adding controls in Popup window

XAML code

    <Popup Name="Popup1" Width="240" Height="200" Placement="Center" IsEnabled="True" IsOpen="True" >
        <Border BorderBrush="DarkCyan" BorderThickness="3">
            <StackPanel Background="Aquamarine" VerticalAlignment="Center" Height="200">
                <StackPanel>
                    <Grid Margin="0,40,0,20" >
                        <Grid.RowDefinitions >
                            <RowDefinition Height=" 30"></RowDefinition>
                            <RowDefinition Height="30"></RowDefinition>
                            <RowDefinition Height=30"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"></ColumnDefinition>
<ColumnDefinition Width="100"></ColumnDefinition>
<ColumnDefinition Width="100"></ColumnDefinition>
</Grid.ColumnDefinitions>

<Label Name="lblPasswordReprint" Content="Password:" Grid.Row="1"
Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Center"/>

<TextBox Name="txtPasswordReprint" Width=" 90" Height="20" Grid.Row="1"
Grid.Column="1" HorizontalAlignment="Left" IsEnabled="True"/>
<Label Name="lblUserName" Content=" UserName:" HorizontalAlignment="Right"
Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" />
<TextBox Name="txtUserNameReprint" Width=" 90" Height=" 20" Grid.Row="0"
Grid.Column="1" HorizontalAlignment="Left"/>
<Button Content="Login" Width="70" Height="30" Grid.Row="2"
Grid.Column="0"HorizontalAlignment="Right" />
<Button Content="Cancel" Width="70" Height="30" Grid.Row="2"
Grid.Column="1" HorizontalAlignment="Left" />
</Grid>
</StackPanel>
</StackPanel>
</Border>
</Popup>

Image of Popup Window

Popup.gif

How to Open a Popup Window?

Popup can be Opend by using Property IsOpen=true.

        private void ButtonShow_Click(object sender, RoutedEventArgs e)
        {
            Popup1.IsOpen = true;
        }

How to Close a Popup window?

Popup window can be closed by using a Property IsOpen=false

        private void ButtonCancel_Click(object sender, RoutedEventArgs e)
        {
            Popup1.IsOpen = false;
        }


 

Login to add your contents and source code to this article
share this article :
post comment
 

Hi , Thanks, You cannot view the design of adding controls in popup window.

Posted by Syed Shakeer Feb 15, 2011

hey nice tutorial , i have been looking for a site like this for a very long time. i just started learning c# and i think WPF will be nice platform to develop desktop application. one thing i have notice is during design time i dont see the controls i add to the popup box except for the outline of the popup it self , i am using VS2010 ultimate. thanks

Posted by sean kofi Feb 14, 2011

Hi, Yes,We can Add DataGrid control in Popup window.Add dataGrid control in Popup Window like we are adding in WPF Form..

Posted by Syed Shakeer Feb 11, 2011

Nice article. Can we have a popup on a grid like control, and get the values displayed on the popup on click of a button in the gridrow Regards, Pravin.

Posted by Pravin Kamane Feb 11, 2011
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
    ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
Become a Sponsor