SilverLight 4学習ノート1——ChildWindowがメインウィンドウに値を渡す方法
3296 ワード
ChildWindow:
FatherWindow:
private string _test;
public string Test //
{
get { return _test; }
set {_test = value; }
}
public event EventHandler OkBtnClicked;// , ok button ,
private void OKButton_Click(object sender, RoutedEventArgs e)
{
if (OkBtnClicked != null)
{
OkBtnClicked(this, new EventArgs());
_test = "test";
}
this.DialogResult = true;// true , fals
}
FatherWindow:
ChildWindow1 childwin = new ChildWindow1();//
public MainPage()
{
InitializeComponent();
childwin.Closed += new EventHandler(childwin_Closed); // , ,
childwin.OkBtnClicked += new EventHandler(childwin_OkBtnClicked);// ok
}
private void childwin_OkBtnClicked(object sender, EventArgs e)
{
MessageBox.Show(childwin.Test);
}
private void childwin_Closed(object sender, EventArgs e)
{
MessageBox.Show(childwin.Test);
}