WPF:事件委托对于不同界面间通信的应用
2024-09-01 03:49:36
界面1内设定点击事件,生成Path用事件传出
public partial class TemplateWindow : Window
{
internal delegate void ConfirmButtonClick(string Path);
/// <summary>
/// 点击确定按钮事件
/// </summary>
internal event ConfirmButtonClick OnConfirmButtonClick;
private void ConfirmButton_Click(object sender, RoutedEventArgs e)
private void ConfirmButton_Click(object sender, RoutedEventArgs e)
{
string Path = “C://User//Path”;
if (null != this.OnConfirmButtonClick)
{
this.OnConfirmButtonClick(Path);
}
this.Close();
}
}
界面二通过事件获取界面1的Path
public partial class User : UserControl
{
private void ShowWindow_Click(object sender, RoutedEventArgs e)
private void ShowWindow_Click(object sender, RoutedEventArgs e)
{
TemplateWindow window = new TemplateWindow ();
window.Show();
window.OnConfirmButtonClick += (Path) =>
{
Console.Writeline(Path);
};
}
}
最新文章
- iOS-常用的辅助工具软件
- Ext4.0 获取选中行及遍历
- Gym 100507A About Grisha N. (水题)
- 【错误总结之(一)】error LNK2038: 检測到“_ITERATOR_DEBUG_LEVEL”的不匹配项: 值“0”不匹配值“2”
- html5test
- iphone与安卓的兼容性问题汇总
- 【菜鸟入门】安装配置eclipse 并编写运行第一个Java程序
- HDU 4372 Count the Buildings:第一类Stirling数
- Atcoder R84 D Small Multiple
- 前端 jQuery
- session会话管理
- eclipse 搭建maven项目
- 数据分析之Numpy库入门
- css display属性
- 有标号的DAG计数
- python全栈开发笔记-----------概要
- poj_3168 平面扫描
- google搜索 site:pku.edu.cn inurl:aspx 即可查找所有动态网页 =====html(静态网页) asp(动态) jsp(动态) php(动态) cgi(网络程序) aspx(动态)
- windows下手动安装pyinstaller(python2.7)
- Linux --centos7 开机启动设置
热门文章
- lower_bound 和 upper_bound 功能和用法
- 记一次linux通过jstack定位CPU使用过高问题或排查线上死锁问题
- 100天搞定机器学习|Day7 K-NN
- sql锁的类型介绍:悲观锁,乐观锁,行锁,表锁,页锁,共享锁,排他锁,意向锁
- ZooKeeper入门(一)
- HDU 6011:Lotus and Characters(贪心)
- MyBatis 基础搭建及架构概述
- Drools规则引擎-判断集合(List)是否包含集合
- Android调试移动端webview
- python之unittest框架实现接口测试实例