开幕&在 Windows 窗体中执行 .xaml
我想知道如何在 Windows 窗体中运行 .xaml 窗体(wpfapplication)?另外一个问题是,我有 2 个项目; Windows 窗体应用程序和Wpf 应用程序,我想将两者结合起来并使其相互依赖,这样如果我单击 Wpf 应用程序上的按钮,我将调用或执行 Windows 应用程序中的方法。这可能吗?任何帮助/指导将不胜感激!
I was wondering how can I run .xaml forms (wpfapplication) in windows form? Plus another question is, I have 2 projects ; windows form application & wpf application, i would like to combine this two and make it dependable to each others such that if I click a button on the Wpfapplication, i would call or execute a method in the windows application. is this even possible? Any help/guide would really be appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,您可以在 Winforms 中托管 WPF 控件。您想查看
ElementHost
类。对于您的另一个问题:如果您正在谈论组合两个应用程序的源代码并基本上为它们创建一个可执行文件,那么它本质上归结为调用库函数 - 所以这是可能的。如果您正在谈论两个独立进程中的两个独立应用程序,那么情况会变得更加复杂:您需要向应用程序添加一个接口,以公开要调用的方法。有很多方法可以做到这一点:WCF、.Net 远程处理、套接字。
Yes, you can host WPF controls inside Winforms. You want to have a look at the
ElementHost
class.For your other problem: If you are talking about combining the sources of both applications and basically make one executable for them then it essentially comes down to calling library functions - so thats possible. If you are talking about two independent applications in two separate processes then then it gets more complicated: you would need to add an interface to your applications exposing the methods to be called. There are many ways to do that: WCF, .Net remoting, Sockets.
在 Windows 窗体中托管 WPF 控件
在 WPF 中托管 Windows 窗体控件
Host WPF Controls in Windows Forms
Host Windows Forms Controls in WPF