Basically I am looking for this Answer, but for Class Libraries.
I am currently maintaining a larger WPF Solution where each part is loaded as a Add-In.
I'd like to create a service for all of these Add-Ins to implement which opens a Window
without using UI elements in the ViewModel, basically looking like this:
class WindowService:IWindowService
{
public void ShowWindow(object viewModel)
{
var win = new Window();
win.Content = viewModel;
win.Show();
}
}
To simplify it, let's say we have 4 Projects:
1. Client
- Client.exe - MainWindow and App.xaml is in here
- Services.dll - Services like WindowService and Reflection are in here
- Interfaces.dll - Contains Interfaces for above assemblies
2. Add-Ins
- AddIn.dll - WPF Class Library, Contains WPF View/ViewModel, References to Interfaces
The Answer I linked defines DataTemplates
in the App.Xaml
, but I can't define DataTemplates
for Classes I don't know at that point, since Add-Ins are loaded using Reflection at Runtime.
Where would I put my DataTemplates
in order to get the linked Answer to work for Class Libraries without an App.Xaml
?