简体   繁体   English

使ActiveX控件关闭其WPF父窗体

[英]Make an ActiveX control close its WPF parent form

I have a custom WinForms ActiveX toolbar control that I want to add to a WPF form. 我有一个自定义WinForms ActiveX工具栏控件,我想将其添加到WPF表单中。 One of the options on the toolbar is to exit the current application. 工具栏上的选项之一是退出当前应用程序。

How can I make the control raise/bubble an event to close the WPF window that contains the control? 如何使控件引发/冒泡事件以关闭包含控件的WPF窗口?

Whatever the technology of your toolbar control, there must be some way to associate a toolbar element click with code in your application (via a delegate, event, etc.). 无论您的工具栏控件采用何种技术,都必须有某种方法将工具栏元素单击与应用程序中的代码相关联(通过委托,事件等)。 Create a method that closes your application and associate it with this toolbar element. 创建一个关闭应用程序并将其与此工具栏元素关联的方法。 See the docs for the Application.Shutdown method for more explanation on terminating the WPF app (including the ShutdownMode enum). 有关终止WPF应用程序(包括ShutdownMode枚举)的更多说明,请参见Application.Shutdown方法的文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM