简体   繁体   中英

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...? 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.

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 .

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. 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. 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.

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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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