Let us assume there is a requirement, On click event of button, a new child window should open. 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>
On the button click event. An instance of Child window is being created. Then ShowDialog() method is being called to open the child window .Read more: C# Corner
<Grid>
<Button x:Name="ButtonNewWindow" Hright="100" Width="Auto" Content="Open new Window" /></Grid>Step 2: Right click on the WPF project and new item and select a WPF Window from WPF tab. Rename window to ChildWindow.xamlStep 3: Now on the click event of button child window will get open. ButtonNewWindow.Click += new RoutedEventHandler (delegate(object sender, RoutedEventArgs e)
{
ChildWindow chlWindow = new ChildWindow();MessageBox.Show(chlWindow.GetMessage());chlWindow.ShowDialog();
}
On the button click event. An instance of Child window is being created. Then ShowDialog() method is being called to open the child window .Read more: C# Corner
0 comments:
Post a Comment