I created a console application that I later decided would function better as a WPF application. I changed the output type to Windows Application and added what I believe are the necessary references. Unfortunately, right-clicking on the project does not allow me to add a Resource Dictionary or many other WPF types. What have I missed?
I did convert my console application to WPF application by below steps
All you need to do is change project type guid in project file.
1. Add reference to PresentationCore assembly
2. Add reference to PresentationFramework assembly
3. Add reference to WindowsBase assembly
4. Go to Project properties then on Application tab change output type to Windows Application.
5. Create new project of WPF application and copy App.xaml and MainWindow or Anyother xaml files to your console application.
And last thing to get Resource dictionary when you right click on project and select add
Open your project file e.g. WpfApp.csproj on notepad And add
**<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>**
in first PropertyGroup element after FileAlignment , it should look like
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{58688A7B-82F4-4229-949A-C4249DAB43FC}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ConsoleApplication1</RootNamespace>
<AssemblyName>ConsoleApplication1</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<StartupObject>
</StartupObject>
Save it. if your project is open in visual sutiod it will ask to reload project, click yes. Thats it, it is now working as WPF Application and you will find Add all menus which are available on WPF application.
The easiest method would be to create a new WPF application and move the code. The best method would be to push the logic into a business library so you can easily use a console application and a wpf application as the presentation technology for the business logic, because WPF is a user interface technology, not an application type.
From a geek standpoint, if you want to solve the hard way to learn, I would create a separate WPF applicationn and examine the proj file. Most likely there is some little bit in there that makes things work as WPF, as well as some missing references.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With