如何像在 Winform 中那样以编程方式在 WPF 中添加事件处理程序 [英] How to add event handler programmatically in WPF like one can do in Winform
本文介绍了如何像在 Winform 中那样以编程方式在 WPF 中添加事件处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这个 winform 指令的等价物是什么:
What's the equivalent of this winform instruction:
this.button1.Click += new System.EventHandler(this.button1_Click);
在 WPF 中?
更新:也适用于滑块.我应该声明什么命名空间?
Update: also for a slider. And what namespace should I declare ?
我的观点是不要使用 XAML.
My point is NOT to use XAML.
推荐答案
类似这样的...
this.btnTest.Click+=new RoutedEventHandler(btnTest_Click);
这篇关于如何像在 Winform 中那样以编程方式在 WPF 中添加事件处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文