我将不得不建立一个WinForms应用程序的自定义控制。但在不久的将来同样的控制将在WPF应用程序中使用。
I'm going to have to build a custom control for a WinForms application. But in the near future that same control will have to be used in a WPF application.
我已经写所有的逻辑,我可以用两个WinForms和WPF(我只会有一些数据绑定做的,就是这样)一个控制器类,但当然会更容易开发和维护控制只有一次。
I've already written all the logic in a controller class which I can use for both WinForms and WPF (I will only have some databinding to do and that's it), but of course it would be easier to develop and maintain the control only once.
所以,我可以建立在WPF控件,然后把它们放在一个WinForms形式? 我的项目目前有3.0作为其目标框架。
So can I build the control in WPF and then put them on a WinForms form? My projects currently have 3.0 as their target framework.
当然可以!
在使用的WinForms ElementHost的并添加WPF内部控制(这里最好的做法是创建一个WPF用户控件并添加控件到用户控件)
In WinForms use ElementHost and add you WPF control inside (Best practice here is to create a WPF User Control and add you controls into the user control)
和WPF中,如果你想使用的WinForms用户控件,使用的WindowsFormsHost
And in WPF, if you want to use a WinForms user control, use the WindowsFormsHost
WPF互操作:空域和窗口区域概述 Windows窗体和WPF属性映射 如何:使用ElementHost的主机在Windows窗体在Windows presentation基金会控制 演练:托管Windows窗体控件在Windows presentation基金会 WPF Interoperation: "Airspace" and Window Regions Overview Windows Forms and WPF Property Mapping How to: Host a Windows Presentation Foundation Control in Windows Forms by Using ElementHost Walkthrough: Hosting a Windows Forms Control in Windows Presentation Foundation上一篇:如何建立RUNAS / NETONLY功能集成到一个(C#/。NET /的WinForms)计划?功能、计划、NETONLY、RUNAS
下一篇:获取SlowAES和RijndaelManaged类在.NET一起玩一起玩、SlowAES、RijndaelManaged、NET