title: Upgrading a WinForms app to WPF
body: <p>I have a side project that I wrote a few years ago in WinForms. To better help me learn WPF, I would like to rewrite it in WPF. Ideally, I would like to just modify the current project that I have and rewrite the UI in WPF instead of creating a new project.</p>
  
  <p>I'm having some problems doing that. I did the following (using Visual Studio 2008 SP1):</p>
  
  <ol>
  <li>Changed the Target Framework from 2.0 to 3.5.</li>
  <li>Added PresentationCore, PresentationFramework, and WindowsBase references. </li>
  </ol>
  
  <p>At this point, I noticed something was amiss. When I right clicked the project and selected Add | New Item, I did not have an option to create a WPF Window - the only WPF class that I could create is a WPF User Control. Since I had some other WPF projects around, I copied App.xaml.* and Window1.xaml.* from that project to mine, and updated them as necessary (basically just changing the namespace of that project to the namespace of my project).</p>
  
  <p>I then deleted Program.cs (which previously contained the Main method, that displayed the main WinForm Form), and built the project. I got an error indicating that there is no Main method.</p>
  
  <p>It seems like internally Visual Studio knows that this project is really a WinForms app, and not a WPF app. In a WPF project (created by selecting "WPF Application"), in the Application properties I can set the instance of the Application class as a start up object. In my WinForms converted project, that isn't an option.</p>
  
  <p>I took a quick look at the .csproj file in a text editor, but I couldn't find anything that would tell Visual Studio that the project is really WinForms rather than WPF.</p>
  
  <p>What else do I need to do to turn my WinForms project into a "real" WPF project? Do I have an option other than creating a new project and just replacing my current project?</p>
  
  <p><strong>Update:</strong> I took a closer look at the .csproj files, and I noticed that App.xaml was added as a page:</p>
  
  <pre><code>&lt;Page Include="App.xaml"&gt;
    &lt;Generator&gt;MSBuild:Compile&lt;/Generator&gt;
    &lt;SubType&gt;Designer&lt;/SubType&gt;
  &lt;/Page&gt;
  </code></pre>
  
  <p>However, in my other WPF project, it is an ApplicationDefinition. Once I changed that, I could set my Application instance as the start up object, and my app would run. I still don't have an option to create any WPF types other than User Controls, though.</p>