简体   繁体   English

WPF和C#项目

[英]WPF and C# project

Hy.I am currently working on a application in windows forms c#.My application is almost finished but the design is awful,i mean is very simple.I've searched some things about WPF and i think is a very good way to improve my design...But my question is:For using WPF only for my interface..if i will make copy -paste of my code, and i will modify only buttons and colors....will my project continue to work?Or I should started from 0...? 嗨。我目前正在使用Windows窗体c#开发应用程序。我的应用程序快要完成了,但是设计很糟糕,我的意思是非常简单。我已经搜索了一些有关WPF的信息,我认为这是改进我的很好的方法设计...但我的问题是:仅将WPF用于我的界面..如果我要复制-粘贴我的代码,并且仅修改按钮和颜色....我的项目会继续工作吗?还是我应该从0开始...? Thank you 谢谢

In general I would recommend to start from scratch. 通常,我建议从头开始。 If you aren't doing a complicated architecture here and have simple event handlers for WinForms you can pretty much stick with the same structure in WPF. 如果您在这里没有做复杂的体系结构,并且拥有用于WinForms的简单事件处理程序,则可以在WPF中坚持使用相同的结构。

Architecturally speaking it would have of course been better to isolate the business logic from the event handlers. 从架构上来讲,最好将业务逻辑与事件处理程序隔离开。 In that regard you might want to take a look at MVVM (and the MVVM Light Toolkit ) and Prism . 在这方面,您可能需要看一下MVVM(和MVVM Light Toolkit )和Prism

We have successfully put a WPF shim around one of our very large WinForms apps and hosted the WinForms parts inside of a windows forms host. 我们已经成功地将WPF填充程序放在一个非常大的WinForms应用程序中,并将WinForms部件托管在Windows窗体宿主中。 This allows you to convert one part at a time. 这样您可以一次转换一个零件。 This might be a route to take if this project is bigger or you are not sure you will be able to convert the entire application in one shot. 如果这个项目更大,或者您不确定是否可以一次转换整个应用程序,这可能是一条途径。

If your win forms app is designed properly you should be able to reuse all but your UI code. 如果您的获胜表单应用程序设计正确,则您应该可以重用除UI代码之外的所有代码。 In my opinion WPF is far superior to win forms and you should definatly consider using it but it will take some learning to get started, dont do thus if you have a deadline coming up soon. 在我看来,WPF远远胜于赢得表格,您应该明确地考虑使用它,但是这需要一些学习才能开始,如果您临近截止日期,请不要这样做。

I also recommend you to move to the MVVM and WPF anyway if your project it is not so big you can use only WPF for interface and copy and paste your code. 我还建议您无论如何都不要迁移到MVVM和WPF,如果您的项目不太大,则只能使用WPF作为界面,并复制和粘贴代码。 But from architecture point of view using the MVVM pattern you can make better separation of the interface (View) and you logic (Model) if you will use MVVM in the future will be easier to maintain and change your application 但是,从使用MVVM模式的架构角度来看,如果将来要使用MVVM,则可以更好地分离接口(视图)和逻辑(模型),这将更易于维护和更改应用程序

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM