从Winforms应用程序调用WPF表单 [英] Calling a WPF form from Winforms application

查看:73
本文介绍了从Winforms应用程序调用WPF表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个项目 - 1个是Winforms应用程序,第二个是WPF表单(都是C#.NET4)。我想通过创建WPF应用程序类的对象(将一些值传递给构造函数)并使用.show()方法从我的winforms应用程序调用WPF表单。 />


我需要一个如何执行此操作的示例,因为我是MVVM模式的新手,我不知道该怎么做。



视图名称= MainWindow.xaml

视图模型的名称viewModel = MyViewModel.cs(我的视图的数据上下文设置为我的视图模型)

模型对于winforms和WPF应用程序都是通用的。

我不确定要创建什么对象来显示WPF表单。



如果你能给我一个示例应用程序的链接,那将是一个很大的优点。

I have 2 projects - 1 is a Winforms application and the second is a WPF form (both C# .NET4). I would like to call the WPF form from my winforms application by creating an object of the WPF application class(passing a few values to the constructor as well) and using the .show() method.

I need an example of how to do this as I am new to MVVM pattern and I am not sure how to do this.

name of view = MainWindow.xaml
name of view model viewModel = MyViewModel.cs (the data context of my view is set to my view model)
the model is common to both the winforms and WPF application.
I am not sure what object to create to display the WPF form.

If you can give me any link to a sample application it will be a big plus point.

推荐答案

我最近遇到了创建systry应用程序作为systry应用程序的示例而不是winform应用程序,尽量减少尝试。长话短说,它包括在同一个程序中使用winform和wpf。

这是文章:

https://www.simple-talk.com/dotnet/.net-framework/creating -tray-applications-in-.net-a-practical-guide / [ ^ ]

和确切的部分:

https:/ /www.simple-talk.com/dotnet/.net-framework/creating-tray-applications-in-.net-a-practical-guide/#fifteenth [ ^ ]



他在那里写道,他是好的,从这里开始:

http://weblogs.asp.net/jdanforth/archive/2008/07/29/open-a-wpf-window-from-winforms.aspx [ ^ ]



也可以从那里去混合wpf和winform

https://www.simple-talk.com/dotnet/.net-framework/mixing-wpf-and-winforms/ [< a href =https://www.simple-talk.com/dotnet/.net-framework/mixing-wpf-and-winforms/target =_ blanktitle =New Window> ^ ]



我希望这会对你有帮助。
I recently come across sample of creating systry application as systry application and not winform application that minimize to the try. long story short it include the using of winform and wpf in the same program.
this is the article:
https://www.simple-talk.com/dotnet/.net-framework/creating-tray-applications-in-.net-a-practical-guide/[^]
and the exact section:
https://www.simple-talk.com/dotnet/.net-framework/creating-tray-applications-in-.net-a-practical-guide/#fifteenth[^]

He wrote there that he took this from here:
http://weblogs.asp.net/jdanforth/archive/2008/07/29/open-a-wpf-window-from-winforms.aspx[^]

also from there you can go to mixing wpf and winform
https://www.simple-talk.com/dotnet/.net-framework/mixing-wpf-and-winforms/[^]

I hope this will help you.


这篇关于从Winforms应用程序调用WPF表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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