parent.xaml
parent.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.Shapes;
namespace WpfApplication3
{
/// <summary>
/// Interaction logic for parent.xaml
/// </summary>
public partial class parent : Window
{
Child open = new Child();
public parent()
{
InitializeComponent();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
if (open != null)
{
open.Close();
open = new Child();
open.openPro += new EventHandler(openProj);
open.ShowInTaskbar = false;
open.Owner = this;
open.ShowDialog();
}
}
private void openProj(object sender, EventArgs e)
{
try
{
label1.Content="this is test delegate";
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "TetroDAS Message", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
}
parent.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.Shapes;
namespace WpfApplication3
{
/// <summary>
/// Interaction logic for parent.xaml
/// </summary>
public partial class parent : Window
{
Child open = new Child();
public parent()
{
InitializeComponent();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
if (open != null)
{
open.Close();
open = new Child();
open.openPro += new EventHandler(openProj);
open.ShowInTaskbar = false;
open.Owner = this;
open.ShowDialog();
}
}
private void openProj(object sender, EventArgs e)
{
try
{
label1.Content="this is test delegate";
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "TetroDAS Message", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
}
Child.xaml :
<Window x:Class="WpfApplication3.Child"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Child" Height="300" Width="300">
<Grid>
<StackPanel Height="100" HorizontalAlignment="Left" Margin="10,10,0,0" Name="stackPanel1" Width="200" >
<Button Content="Display" Height="23" Name="button1" Width="75" Click="button1_Click" />
</StackPanel>
</Grid>
</Window>
Child.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.Shapes;
namespace WpfApplication3
{
/// <summary>
/// Interaction logic for Child.xaml
/// </summary>
public partial class Child : Window
{
public event EventHandler openPro;
public Child()
{
InitializeComponent();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
this.Hide();
if (openPro != null)
{
openPro(this, new EventArgs());
}
}
}
}


No comments:
Post a Comment