This came up for me recently, the issue is that by creating a class library you shouldn't have an application. You can still have an Application.xaml with merged dictionaries but that only half worked for me: certain resources from one dictionary were found but a control template for the window wasn't even though the designer found it.
In the end I did it programmatically by created a static method that merged the resource dictionary in the ctor of the window. The downside of this is at design time I have to imagine what it looks like. Although I can template a window to take on the appearance for that purpose.
There is this property called Application.ResourceAssembly that can only be set once.
Public Shared Sub Initialise(W As Window)
Dim TW As Boolean
If W.WindowStyle = WindowStyle.ToolWindow Then
TW = True
End If
W.AllowsTransparency = True
W.WindowStyle = WindowStyle.None
If Application.ResourceAssembly Is Nothing Then
Application.ResourceAssembly = System.Reflection.Assembly.GetExecutingAssembly
End If
Dim RD As New ResourceDictionary
RD.Source = New Uri("pack://application:,,,/Resources/CustomWindow.xaml", UriKind.RelativeOrAbsolute)
W.Resources.MergedDictionaries.Add(RD)
Dim Sty As Style = Nothing
If TW Then
Sty = RD.Item("RPT_CustomToolWin")
Else
Sty = RD.Item("RPT_CustomWin")
End If
W.Style = Sty
End Sub
I think generally we shouldn't have that many windows for an add-in (how many corridors do you want to walk down to get to a room).