I have a project containing a xaml ResourceDictionary that I wish to use outside of a FrameworkElement. The resource dictionary will contain a DataTemplate for a class local to the project to avoid polluting the app.xaml (as the project is a prism module, and will not always be present depending on config).
So, I have a test.xaml file with a Resource build action.
This is intended to supply the DataTemplate for a TestObject class.
In the TestObject class I have a GetTemplate() method
The following works:
DataTemplate GetTemplate()
{
Uri uri = new Uri("MyProject;component/test.xaml", UriKind.Relative);
var dict = new ResourceDictionary { Source = uri};
return (DataTemplate)dict["TestObjectDataTemplate"];
}
This throws an exception when I assign the uri to the ResourceDictionary.Source property
DataTemplate GetTemplate()
{
Uri uri = new Uri("/test.xaml", UriKind.Relative);
var dict = new ResourceDictionary { Source = uri};
return (DataTemplate)dict["TestObjectDataTemplate"];
}
The second example fails as the /test.xaml can't be found in the local assembly. Why would I need to access it with "ReferencedAssembly;component/test.xaml" ?
In this instance, does local assembly mean the executing assembly or the assembly the code/resource is part of?
Edit: Updated to reflect the actual issue.