1

My need is to develop an addin for an application but WPF application is not allowing to build it in type of WPF Class Libarary Refering to this question i found that without XAML pages only we can build WPF application in Class Library Type. It it true? Or am I missing something?

I need to add a WPF window to my addin, but they are referring to remove all the windows and add usercontrol? Whats the workaround for it? Or am i doing anything wrong?

What i did now is I just deleted my application.xaml window from my solution and changed the target type to WPF class Libarary and builded the solution and it builded successfully. Is it correct way..? or any other ways there..? Am really new to this WPF !

Community
  • 1
  • 1
Dah Sra
  • 4,107
  • 3
  • 30
  • 69

2 Answers2

0

Yes, you can go on creating a Class Library, adding a XAML view there. In your exe project you will include a reference to that lib and its public XAML windows or user controls should be available under the library's namespace, like any C# class.

Edit

A simple example from GitHub: as you can see, the library project is compiled with a reference to the System.Xaml assembly.

Edit 2

To build an already existing Windows Application project into a Class Library one, besides changing the Output type you have to delete only the App.xaml

0

There two additional templates to build WPF dll's such as WpfCustomControlLibrary and WpfControlLibrary. You will then be able to add a Window (and other WPF-specific elements). And it can certainly contain general-purpose classes. And it will be built into an assembly no different from that from general class library project.

How to: Create a WPF UserControl Library Project

How to add a WPF control library template to Visual C# Express 2008

If you want just create class libary, please, just select Class Library

How to: Create Class Library.

Also, you can add Window to general class library project. Visual Studio just does not expose Window from add new items dialog. A workaround is to add a User Control Item, and then change it to derive from Window.

StepUp
  • 36,391
  • 15
  • 88
  • 148
  • @dahsra Feel free to ask any question. If you feel that my reply helps to you, then you can mark my reply as an answer to simplify future search of other people. Please, read this http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work – StepUp May 06 '16 at 15:20