子窗体传值到父窗体

2016-12-16 18:58:34来源:CSDN作者:ze_sky人点击

Window2.xaml.cs

public event EventHandler accept;private void Button_Click(object sender, RoutedEventArgs e){    accept("这里是要传递的信息", EventArgs.Empty);    this.Close();}

Window1.xaml.cs

值会传递到str,即 str=”这里是要传递的信息”

private void Button_Click(object sender, RoutedEventArgs e){    Secend win=new Secend();    win.accept += new System.EventHandler(Win_accept);    win.ShowDialog();}string str = null;private void Win_accept(object sender, System.EventArgs e){    str = (string)sender;}

最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台