If you start building your class library on a green field I would suggest this:
1. Start with a new
WPF Application project
2. Add your UI components as you usually do
3. In
Solution Expoler right click on the project and choose
Properties
4. On
Application tab change
Output type from
Windows Application to
Class Library
5. To get rid of compilation errors delete the
App.xaml file from your project
After all this, when you build this particular project you will get a DLL, that can be used in other projects.
If you already have some Class Library project, than you can add references to libraries that are needed for WPF, as Pheonyx mentioned in their comment, but Visual Studio can do it by itself.
1. Right click on your
Class Library project
2. Choose
Add > New Item
3. In the left bar from
Visual C# items select
WPF > User Control (WPF)
4. To use XAML add reference to Windows.XAML assembly (
Project > right click on
References > Add Reference > from
Assemblies add
Windows.XAML )
In the project, where you want use the library:
1. Add the output DLL to References / or just reference your Library project
2. Considering that the namespace of your library is ClassLibrary1 your can use its components in XAML with this code:
<Window
...
xmlns:lib="clr-namespace:ClassLibrary1;assembly=ClassLibrary1"
...
>
<lib:UserControl1 /> <!-- User Control from the library -->
</Window>