5

I have a Winform app that has one very simple form, a program.cs main file and about 60 back-end .cs files. I want to convert the project to a WPF application. Looking here didn't show anything close to what I want to do.

I need to

  • Convert the csproj file so it will allow me to add WPF windows
  • That conversion to be done "in place" to keep my source control tidy and avoid the trouble of adding back all the back end files in their proper folders, add the references to external dependencies, etc.
  • Create one empty mainwindow.xaml (+.cs) file that I will manually fill with the appropriate controls.

Then, I will manually split the content of the old forms file between the view and the viewmodel files.

Any way of doing that easier than starting from scratch?

EDIT: I would rather not host the new WPF ui into the old winforms shell but replace the current forms application by a wpf one.

EDIT2: I do not want to convert the entire project and the architecture to WPF (as it was asked and answered several times on SO), I totally understand that these are 2 different framework and I am totally willing to do the change manually. I want to convert the csproj so it will compile as a WPF app instead of a Forms app.

Vincent Hubert
  • 1,386
  • 9
  • 23
  • 2
    Anything related with **coding** ? – L.B Jun 02 '14 at 18:44
  • http://stackoverflow.com/questions/3685142/mixing-wpf-with-a-winform-application – Alexei Levenkov Jun 02 '14 at 18:47
  • 2
    I would definitely start from scratch. If the logic is that common, you could make the "back-end" files their own assembly. This is defintiley about programming, if not coding though. – BradleyDotNET Jun 02 '14 at 18:48
  • @Alexei: From the FAQ:"With your help, we're working together to build a library of detailed answers to every question about programming." My understanding is that configuring your visual studio project to build an application is "programming" isn't it? Or should convert the project to a makefile and then as a question about it? – Vincent Hubert Jun 02 '14 at 18:52
  • I believe this is on-topic, and the answer is, "start over, there's no conversion available". – John Saunders Jun 02 '14 at 18:53
  • @VincentHubert I'm not sure why you addressed your comment to me - it was not clear if your question is duplicate of "use WPF in WinForms" or not - so you edit made clear that you want conversion (which does not exist in VS) - closed as dup found by icemanind. – Alexei Levenkov Jun 02 '14 at 18:59
  • This [SO Question](http://stackoverflow.com/questions/5652000/winform-conversion-to-wpf) should answer your question. – Icemanind Jun 02 '14 at 19:00
  • @Alexei, Well, as you correctly guessed, you were not the intended recipient. Comment should have gone to L.B. – Vincent Hubert Jun 02 '14 at 19:14
  • Try creating an empty Winforms project, then creating an empty WPF project, then comparing the two project files. – John Saunders Jun 02 '14 at 19:16
  • @JohnSaunders, I did quite like that, and it worked. How do I get this question re-opened so I can mark that answer? – Vincent Hubert Jun 02 '14 at 19:55

2 Answers2

13

The short answer for those that don't want to do the comparison themselves is that a WPF .csproj file contains an addition property:

<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

Just put that in the first <PropertyGroup>...</PropertyGroup> section, it shouldn't matter where.

The meaning of {60dc8134-eba5-43b8-bcc9-bb4bc16c2548} is that this is a WPF project, and {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} indicates a C# project. You can learn more about project type guids from this SO question.

Community
  • 1
  • 1
othp
  • 321
  • 3
  • 6
0

It seems from your edit2 that you just want to change the project type from "Winforms" to "WPF" without changing any of the project items. I don't know why you want to do this, but try creating an empty Winforms project, then creating an empty WPF project, then comparing the two project files.

Whatever the difference is between the two empty projects, make that change to your existing Winforms project.

John Saunders
  • 160,644
  • 26
  • 247
  • 397