父窗口:
///<summary>
///弹出窗口
///</summary>
///<param name="sender"></param>
///<param name="e"></param>
privatevoid miFuncSet_Click(object sender, RoutedEventArgs e)
{
WinFuncSetting funcSetting =new WinFuncSetting();
funcSetting.ChangeTextEvent +=new ChangeTextHandler(FuncSettingClosed);
funcSetting.ShowDialog();
}
//设置窗口关闭时执行的方法
void FuncSettingClosed()
{
//写你想调用的方法,如重新绑定数据源啊 改变某标签的值啊 等等
}
子窗口:
namespace EFM.FuncTest.assist
{
//定义委托
publicdelegatevoid ChangeTextHandler();
///<summary>
/// FuncSetting.xaml 的交互逻辑
///</summary>
publicpartialclass WinFuncSetting : Window
{
publicevent ChangeTextHandler ChangeTextEvent;
public WinFuncSetting()
{
InitializeComponent();
}
//窗口关闭事件 你可以在任意你需要的操作后触发事件,我这里是写在窗口关闭里
privatevoid Window_Closed(object sender, EventArgs e)
{
StrikeEvent();
}
//触发事件改变MainWindow的值
privatevoid StrikeEvent()
{
if (ChangeTextEvent !=null)
{
ChangeTextEvent();
}
}
}