if I want to bind a view to a viewmodel I add the following to the resources of my XAML-Code:
<Window.Resources>
<DataTemplate DataType="{x:Type MyViewModel}" >
<views:MyView />
</DataTemplate>
</Window.Resources>
Is there any possibility to add the (viewmodel,view)-resource-entry to my resources dictonary in C#-Code?
The following two lines create the key and add it to the dictonary:
DataTemplateKey key = new DataTemplateKey(typeof(MyViewModel));
View.WindowName.Resources.Add(key, value);
But how can I create the value from the MyView
which must have the type System.Windows.Baml2006.KeyRecord
?