Reputation: 878
Is it possible to reference DataTemplate which is located in another assembly in DataTemplateSelector.
Currently I have something like this:
public override DataTemplate SelectTemplate(object item, DependencyObject container)
{
var element = container as FrameworkElement;
if (element != null && item != null && item is BrowserBaseViewModel)
{
return element.FindResource("BrowserDataTemplate") as DataTemplate;
}
return null;
}
But it works only with current assembly.
Upvotes: 1
Views: 1395
Reputation: 11051
Sure, write in your app.xaml
a ResourceDictionary "include" so the dictionary can be found in your application.
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/MyOtherAssembly;component/MyAssemblyXaml.xaml" />
Now your data template will be found, because the resource lookup will look into the app.xaml resources, and find your referenced xaml.
Upvotes: 4