0% found this document useful (0 votes)
13 views3 pages

Child Window in WPF

1. The document discusses opening a child window from a button click event in a WPF application. 2. It provides steps to create a WPF application with a button, create a child window, and open the child window using the ShowDialog() method when the button is clicked. 3. This makes the parent window inactive while the child window is open, as required.

Uploaded by

Abhi
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views3 pages

Child Window in WPF

1. The document discusses opening a child window from a button click event in a WPF application. 2. It provides steps to create a WPF application with a button, create a child window, and open the child window using the ShowDialog() method when the button is clicked. 3. This makes the parent window inactive while the child window is open, as required.

Uploaded by

Abhi
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

Child Window 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.

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

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

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

Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy