如何从WPF按钮单击事件中引发winforms用户控件按钮单击事件

问题描述:

您好我正在创建具有按钮控件事件的winforms用户控件,该用户控件在MY WPF项目中使用。问题是我没有得到如何从我的WPF应用程序中引发按钮点击事件,这将引发Winforms用户控制按钮点击事件



我尝试过:



尝试从wpf按钮

Hi i am creating winforms user control which has a button control event,That User control is used in MY WPF project. And problem is i am not getting how to raise button click event from my WPF application which will raise Winforms user control button click event

What I have tried:

Trying to raise winforms user control button click event from wpf button

As提升winforms用户控制按钮点击事件我理解你想要的那个例子,例如由UserControl上的Button引发的Click-Event应该来自UserControl。 UserControl上的Button不应该在Control之外。



如果这是正确的,你只需要捕获UserControl中的Button.Click(用一个简短的方法) )并使用此方法从UserControl调用(受保护的)OnClick方法。
As I understood your requirement you want that for example the Click-Event, which is raised by the Button on the UserControl, should come from the UserControl. The Button on the UserControl should not be known outside the Control.

If this is right you only need to catch the Button.Click inside the UserControl (with a short method) and with this method you call the (protected) OnClick-Method from the UserControl.