In my prism module, I have the following code snippet:
using (var manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MyAssembly.CaseHost.ViewModelDataTemplates.xaml"))
{
ParserContext context = new ParserContext();
context.XmlnsDictionary.Add("local", "clr-namespace:MyAssembly.CaseHost");
var resourceDictionary = (ResourceDictionary)XamlReader.Load(manifestResourceStream, context);
_resourceRegistry.Add(resourceDictionary);
}
I’m basically trying to load up this very simple ResourceDictionary:
<DataTemplate DataType="{x:Type local:PlayPauseViewModel}">
<Label>Look mom!</Label>
</DataTemplate>
This gives me the following exception:
Type reference cannot find public type named ‘PlayPauseViewModel’.
This is a cpp/winforms/wpf application beast, so I can’t use URI’s. How can I solve this?
Found it!
The problem was how the namespace was specified in the DataTemplate:
Standard definition (did not work):
More explicit definition (worked!)
Replace <> with namespace and assembly.