6

Can I Convert my whole WinForm Application to wpf application?. I wants to convert my Accounting Software to Wpf Is it possible?.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
mahesh
  • 1,370
  • 9
  • 36
  • 61

3 Answers3

16

No - there is no direct translation from Windows Forms to WPF - in addition, doing this directly would be poor, and lead to a very poorly designed WPF application.

I discuss this in depth in my series on WPF with MVVM - in particular, "Part 3" shows what happens when you write WPF using the same manner as typical Windows Forms applications, but then I go onto show why this is a bad idea in general.

WPF, at its core, is built upon a very different programming paradigm than Windows Forms. It would be better to separate out your business logic in Windows Forms, then write a new View layer in WPF to work with the logic.

Reed Copsey
  • 554,122
  • 78
  • 1,158
  • 1,373
  • 2
    +1 for the different paradigm. I wrote a silverlight app just like a windows forms app and having so much trouble updating it because UI and logic and all stuck together. Since then I truly understand the value of MVVM. – gideon Apr 13 '11 at 15:54
  • What you think about third party tools or software for conversion? – mahesh Apr 13 '11 at 17:15
  • 2
    @mahesh: I'd recommend reading my series at: http://reedcopsey.com/series/windows-forms-to-mvvm/ You'll find that, even if you do find a 3rd party solution that will convert, the conversion will, in general, be worse than useless - you're better off doing it manually. You can always use the interop layers to convert content in stages. – Reed Copsey Apr 13 '11 at 17:16
  • I am converting a Winform application with MVP architecture to WPF. Of course, MVP in this case is utilizing events in Winform. And after I've read your blog, I cannot find any reason that we need to change the event-driven architecture to MVVM. Am I missing something? – Tae-Sung Shin Apr 16 '13 at 15:25
  • 1
    @Thomas You don't need to change it - WPF will work this way. You'll find that, over time, it's often more effective to change it, though. Being event driven everywhere makes WPF less flexible and a bit more rigid, but is often easier for the transition... – Reed Copsey Apr 16 '13 at 15:50
1

Its not like converting vb.net to C# or something, WPF is a totally different way of writing windows apps.

However, if you have your code cleanly abstracted, and/or your UI code separated from logic, you shouldn't have too much trouble porting it to WPF.

WPF also does have the WindowsFormsHost class. Here is a Walkthrough on Hosting a windows forms control in WPF.

gideon
  • 19,329
  • 11
  • 72
  • 113
0

you'll need to rewrite quite a lot. And it's definitely worth doing to take advantage of MVVM.

Charbel
  • 14,187
  • 12
  • 44
  • 66