从打开的WinForms和放一个WPF窗口;与WPF应用程序链接的形式应用 [英] Open a WPF Window from WinForms & link form app with WPF app

查看:264
本文介绍了从打开的WinForms和放一个WPF窗口;与WPF应用程序链接的形式应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用Visual Studio 2012和放大器;我使用的是被称为Form1上与放运表格应用;加上这是WPF窗口被称为wpfWin的新项目。我想通过在Form1一个按钮,打开wpfWin一旦它被点击,它打开了 - 分离的窗口 -

I'm using Visual studio 2012 & I'm using Win Form app called Form1 & add a new item which is wpf Window is called "wpfWin". I want to open the wpfWin through a button in the Form1 once it's clicked, it opened - separated windows-.

我已经试过的 weblogs.asp ,但我还没有发现WPF自定义控件库&放大器;一旦我跳过它时出现的错误。 ?!有没有其他办法

I have tried weblogs.asp but I haven't found the "WPF Custom Control Library" & once I skip it an error appeared. Is there any other way?!

另外,我怎么能连接两个应用程序之一在winform和放大器;其他WPF?!

Also, how can I link Two applications one in WinForm & the other Wpf ?!

推荐答案

在WindowsForm APP 让您有上面的教程链接的问题和质疑打开WPF窗口?在WPF自定义控件库,是你想要在你的Win-窗体应用程序使用WPF窗口。

Open WPF window in WindowsForm APP so you are having issues with the above linked tutorial and question? The "WPF Custom Control Library" is the WPF window that you want to use in your Win-Forms app.

只是一个简单的解释,因为它是解释得通了几次这个问题和教程。您将要打开你当前工作的双赢形式的项目。然后你会想要去解决方案资源管理器,用鼠标右键单击该解决方案,而不是项目,进入添加,然后选择新建项目。

Just a brief explanation as it is explained a few times through the question and tutorial. You will want to open the win-forms project you are currently working on. Then you will want to go to Solution Explorer and right-click the SOLUTION, not the project, go to "Add" and select "New Project".

在加新项目去的Visual C#,然后点击Windows在树的左侧。它们应位于已安装的子菜单。在主要部分,你应该看到WPF自定义控件库,点击它,然后将其命名为你想要什么,然后点击确定。

In the add new Project go to Visual C# and then Windows in the tree on the left hand side. They should be located in the installed sub menu. In the main section you should see "WPF Custom Control Library" click on it and then name it what you would like and click ok.

一个窗口(WPF)控件添加到项目中,该窗口将要打开WPF窗口。

Add a Window(WPF) control to the project, this window would be the WPF window that you want to open.

然后从WinForm的,打开它就像这样:

Then from the WinForm, open it like so:

var wpfwindow = new WPFWindow.Window1();
ElementHost.EnableModelessKeyboardInterop(wpfwindow);
wpfwindow.Show();



不过确保你有以下using语句:

However ensure you have the following using statements:

using System; //Given 
using System.Windows.Forms; //Given
using System.Windows.Forms.Integration; //Not so Given.

您将需要添加一些参考以及正确使这项工作,这里是清单应是你所需要添加到一个双赢的形式:

You will need to add some references as well to make this work correctly, here is the list which should be all you need to add to a win-forms:

 PresentationCore
 PresentationFramework
 WindowsFormsIntegration
 System.Xaml
 YourWpfControlProjectName

您应该使用这些添加到您的Win-形式项目在VS参考选择器通过右键单击在Solution Explorer中的参考文件夹并添加一个新的参考。所有的参考文献都位于框架标签,SANS您的WPF对照,其是在溶液标签

You should add these to your Win-forms project using the reference picker in VS by right-clicking the reference folder in the solution explorer and adding a new reference. All of the references are located in the Framework tab, sans your WPF control which is in the solution tab.

这篇关于从打开的WinForms和放一个WPF窗口;与WPF应用程序链接的形式应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆