Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Browse by Tags · View All
BRH 58
#ASP.NET 55
ASP.NET 50
#DOTNET 49
.NET 40
WCF 21
DOTNET 12
c# 8
windows azure 7
SILVERLIGHT 7

Archive · View All
April 2011 9
March 2011 9
February 2011 8
December 2010 7
November 2010 5
September 2010 5
August 2010 5
May 2011 4
October 2010 4
January 2011 2

Child Window in WPF

Oct 5 2010 2:34PM by Dhananjay Kumar   

In WPF we can work with child window as dialog box. This article will provide you an explanation that how could we work with child window and dialog box in WPF


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.

<grid>
<button content="Open New Window" x:name="BtnNewWindow" height="100" width="Auto">
</grid>

Step 2

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

clip_image004

Step 3

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

BtnNewWindow.Click += newRoutedEventHandler(delegate(object sender, RoutedEventArgs e)
                                             {
                                                 ChildWindowchldWindow = newChildWindow();
                                                 MessageBox.Show(chldWindow.Getmessage());
                                                 chldWindow.ShowDialog();
                                             });

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;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Windows;
usingSystem.Windows.Controls;
usingSystem.Windows.Data;
usingSystem.Windows.Documents;
usingSystem.Windows.Input;
usingSystem.Windows.Media;
usingSystem.Windows.Media.Imaging;
usingSystem.Windows.Navigation;
usingSystem.Windows.Shapes;

namespace WpfApplication2
{
    ///
    /// Interaction logic for MainWindow.xaml
    ///
    publicpartialclassMainWindow : Window
    {
        publicMainWindow()
        {
            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.

clip_image007

Tags: #DOTNET, DOTNET, #ASP.NET, ASP.NET, BRH, XAML,


Dhananjay Kumar
49 · 4% · 1198
0
Liked
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

Your Comment


Sign Up or Login to post a comment.

    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]