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?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Generic Generics in Managed C++
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
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.
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
in first PropertyGroup element after FileAlignment , it should look like
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.
I started to edit the answer from RAJ (as the steps listed there are incomplete), but my changes were a little too drastic, so I decided to post my answer separately.
You can convert a console application to a WPF application with these steps:
ApplicationDefinition
(as described here).Change the project type guid. To do this, edit your project file (e.g. WpfApp.csproj) either in Notepad++ or directly in Visual Studio, adding the following line somewhere in first PropertyGroup element:
Reload your project in Visual Studio.
Like everyone else said, the practical way of making a WPF is to just start a new WPF application project and adapt your console code. However, Gregory A Beamer is correct at pointing out that you may want the geek solution.
Maybe this would be the place to look for the right option:
In the menu, hit Tools >> Customize. In the "Customize" dialog, hit the "Commands" tab, and then click on the "Editor Context Menus" radio button. You can now edit all the context menus in VS. I assume these context menus get automatically customized for each application type. The context menu used to add a resource dictionary to the project should be somewhere in here. Though changing them manually may be a pain in the behind, the geek point is that they're still there.