SIGN UP MEMBER LOGIN:    
ARTICLE

Child Window in WPF

Posted by Dhananjay Kumar Articles | WPF with C# September 06, 2010
In this article you will learn how to use Child Window in WPF.
Reader Level:

Let us assume there is a requirement,

  1. On click event of button, a new child window should open.

  2. While child window is open, the parent window should be inactive.


So start with

Step 1

Create a WPF application. And drag and drop a Button on the MainPage.

child1.gif

Step 2
 
Right click on the WPF project and new item and select a WPF Window from WPF tab. Rename window to ChildWindow.xaml

child2.gif

Step 3

Now on the click event of button child window will get open.

child3.gif

On the button click event

  1. An instance of Child window is being created

  2. Then ShowDialog() method is being called to open the child window .

MainPage.Xaml.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApplication2
{
///<summary>
///
Interaction logic for MainWindow.xaml
///</summary>
public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
        BtnNewWindow.Click += newRoutedEventHandler(delegate(object sender, RoutedEventArgs e)
        {
            ChildWindowchldWindow = newChildWindow();
            MessageBox.Show(chldWindow.Getmessage());
            chldWindow.ShowDialog();
             });
        }
    }
}

So on running on the click of button new child window being open.

child4.gif

 

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

This was a significant ruling for the English courts, where pre-nups have until now carried little weight.wholesale evening dresses Instead, courts have used their powers decide how financial issues should be decided in family cases, plus size formal evening gowns irrespective of the agreements parties may have reached outside the courtroom.

Posted by lm yh Oct 27, 2010
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Become a Sponsor