I have a window in which I want to display dynamic content based on a datatemplate.
The XAML looks roughly like this:
<Window x:Class="Report.ControlLibrary.ReportHost"
xmlns:reports="clr-namespace:Report.ControlLibrary.Reports"
\>
<Window.Resources>
<DataTemplate x:Key="ReportTemplate" DataType="{x:Type reports:ReportViewModel}">
<!-- Markup for DataTemplate goes here -->
</DataTemplate>
</Window.Resources>
<ContentControl Content="{Binding}">
</ContentControl>
</Window>
The DataContext is being set by:
var vm = new ReportViewModel();
var report = new ReportHost() { DataContext=vm };
report.Show();
It seems like the DataContext on the Window is set correctly but the DataTemplate is not found as the window just contains the ToString representation of my ViewModel.