如何创建使用可重新加载插件的 WPF 应用程序?
我手头有一个有趣的问题。
我需要创建一个 WPF 应用程序来托管多个用户控件。 (该应用程序就是这样做的 - 用作具有 UserControls 对接功能的容器)
该应用程序还将托管 UserControls 的数据模型作为另一个热插拔组件。 (我计划为每个组件使用内部队列,以便可以交换组件。)
这些用户控件必须是可插入的(这很容易),并且在运行时可重新加载(这似乎很困难/不可能)。(AppDomains 似乎是这里的答案,但我不知道除了 AppDomain 之外对 MarshalByValue 和 marshalByRefObject 的限制是否有任何 GUI 限制?)在运行时“可重新加载”,就像在应用程序启动时热交换 UI 组件一样。
我还希望用户控件上的上下文菜单包含来自主机的一些项目和来自用户控件本身的一些项目。
我还具有在主机和用户控件之间无缝控制焦点(更改焦点事件上的边框颜色等)的逻辑(跨主机和用户控件进行选项卡)。
顺便说一句,我还希望 UserControl 能够启用 ActiveX,以便与 Excel 等 ActiveX 容器集成。
这将使我能够灵活地运行 UserControl 本身(单元测试)、在容器中运行(无缝导航以及与容器和其他相关 UserControl 的集成)以及作为 ActiveX 控件与 ActiveX 容器集成。
我想知道是否可能,以及是否有框架(MAF?)支持这一点。任何指向示例或文档的指针都会有所帮助。
预先感谢您,
问候, 文。
I have an interesting problem at hand.
I have a need to create a WPF Application which will host several UserControls. (The application does just that - serves as a container with docking abilities for UserControls)
The application will also host the data model for the UserControls as another hot Swappable component. (I plan to use internal queues for each Component so that Components can be swapped.)
These user controls will have to be pluggable (This is Easy), and reloadable (This seems to be difficult/ impossible) at run time.(AppDomains seem to be the answer here, But I don't know the limitations other than AppDomain limitations on MarshalByValue and marshalByRefObject Are there any GUI limitations? ) "Reloadable" at runtime as in Hot Swap the UI component while the app is UP.
I also want the Context menu on a UserControl to have some items from Host and some Items from the UserControl itself.
I also have logic to control Focus (Change Border Color etc. on Focus Events) between the host and UserControls seamlessly (Tabbing across Host and UserControls).
As an aside, I would also want the UserControl to be ActiveX enabled for integration with ActiveX containers like Excel.
This will give me flexibility in terms of running the UserControl by itself (Unit test), In a container (seamless Navigation and integration with container and other relevant UserControls), and as ActiveX control to integrate with ActiveX containers.
I would like to know if it is possible, and if there are frameworks(MAF?) that supports this. Any pointers to examples or documentation will help.
Thank you in advance,
Regards,
Ven.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我一直在探索类似的场景。根据您的描述,MAF 似乎是您最好的选择。 MSDN 文档位于此处。 此 Codeplex 站点包含正在运行的 MAF 工具和示例。希望这有帮助。
I've been exploring a similar scenario. Based on your description, MAF seems like your best bet. The MSDN documentation is here. This codeplex site contains tools and samples of MAF in action. Hope this helps.