[英]Is it possible to implement WPF in already developed C# Windows form application Without Changing Existing code?
i am working with C# windows form application i developed project in that.i like to make project design into more stylish and modern.is it possible to do like this by using WPF,if yes i like to apply WPF code without change Existing code and design,Is it possible to do like this. 我正在使用C#Windows窗体应用程序开发项目,因此我希望使项目设计更加时尚和现代。是否可以通过使用WPF来做到这一点,如果是的话,我希望不更改现有代码即可应用WPF代码设计,是否有可能这样做。
For Example i am putting one button name OK if i click OK i show hai in Message Box but my button view is just usual one i like to change the button stylish using WPF without changing that click event. 例如,如果我单击“确定”,我将一个按钮名称确定为“ OK”,我在消息框中显示hai,但我的按钮视图只是通常的一个,我想使用WPF更改按钮的样式而不更改该单击事件。
if you wanna use WPF styles in a Window Form app, its not possible but you can use a WPF Host in your window form app and add your WPF user controls in that and get more or less the view you are looking for... 如果您想在Window Form应用程序中使用WPF样式,那是不可能的,但是您可以在Window Form应用程序中使用WPF Host并在其中添加WPF用户控件,从而获得或多或少的所需视图...
take a look at here : Host a WPF Control in a Win32 Application 在这里看看: 在Win32应用程序中托管WPF控件
Windows forms is not WPF and WPF is not windows forms. Windows窗体不是WPF,WPF不是Windows窗体。 You can NOT "style" a winforms application, at least, not easily.
至少,这不容易,您不能“样式化” winforms应用程序。 You would have to use some kind of "skinning" library.
您将不得不使用某种“皮肤”库。 In most cases, your non-UI code from your winforms app can be used in the WPF app.
在大多数情况下,可以在WPF应用程序中使用Winforms应用程序中的非UI代码。 For example, a SOAP web service or WCF service.
例如,SOAP Web服务或WCF服务。
You can, in some cases, put a WPF control in your windows form app, and vice versa. 在某些情况下,您可以将WPF控件放入Windows窗体应用程序中,反之亦然。 it would be like taking your windows form app and putting in ASP.NET.
就像将您的Windows窗体应用程序放入ASP.NET。 You are talking about 2 different platforms.
您正在谈论2个不同的平台。
To make these sort of architecture changes you would need to refactor all your logic away from the UI, and then rewrite the UI on top of a business or service layer. 要进行这类体系结构更改,您需要将所有逻辑从UI重构出来,然后在业务或服务层之上重写UI。
As an example, your click event would need to have its code removed and moved to a Amodel or viewmodel, and perhaps replace the Message box with a call to a message box service, which could be stubbed for testing. 例如,您的click事件将需要删除其代码并将其移至Amodel或viewmodel,并且可能用对消息框服务的调用来替换“消息框”,可以将其存根进行测试。
This sort of refactoring can be done slowly using the technique described by Dr TJ, or you could spend your time refactoring code out of your UI layer, and then replace the UI layer in one hit later. 可以使用TJ博士描述的技术来缓慢地进行这种重构,或者您可以花时间在UI层之外重构代码,然后在以后的一击中替换掉UI层。
因此,改写一下:您想更改程序而不更改程序吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.