简体   繁体   English

在WinForms中集成WPF控件而不允许访问其他WPF控件?

[英]Integrating a WPF control in WinForms without allowing access to other WPF controls?

I need the DocumentViewer WPF control (for XPS files) in a Windows Form application. 我需要Windows窗体应用程序中的DocumentViewer WPF控件(用于XPS文件)。 This is actually simple, but I'm not allowed to link in WPF assemblies. 这实际上很简单,但是不允许我在WPF程序集中链接。 My boss' reasoning is that people will start using WPF controls which are incompatible with some of our software. 我老板的理由是,人们将开始使用与我们的某些软件不兼容的WPF控件。 I can't change any of this; 我不能改变任何一个。 it has to be XPS and cannot bring in more than one WPF control. 它必须是XPS,并且不能引入多个WPF控件。 I can use this control if I had a way to link it and only it (no other WPF controls/classes) to our software. 如果我有办法将其链接,并且只有它(没有其他WPF控件/类)链接到我们的软件,则可以使用该控件。

Is it possible for me to write some sort of wrapper on the control in a WPF Class library, and then import that DLL but the DLL does not allow access to other WPF controls? 是否可以在WPF类库中的控件上编写某种包装程序,然后导入该DLL,但该DLL不允许访问其他WPF控件? Is there a way for me to extract just that WPF control from the Presentation Framework assembly (probably not, and this sounds like something that violates the EULA)? 我是否有办法从Presentation Framework程序集中仅提取WPF控件(可能不是,这听起来像违反EULA)?

Or does anyone have a different approach they would like to suggest? 还是有人建议使用其他方法?

And no, not PDF please. 不,请不要PDF。

Just make a class library that does nothing but exposes a (Windows Forms) UserControl. 只需创建一个不执行任何操作,但公开一个(Windows Forms)UserControl的类库即可。 Inside of this UserControl, put your ElementHost with the DocumentViewer. 在此UserControl的内部,将ElementHost与DocumentViewer一起放置。 This way, you'll only load your project's UserControl, and the "WPF Controls" are isolated in the separate project. 这样,您将仅加载项目的UserControl,并且“ WPF控件”被隔离在单独的项目中。

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

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