I have a UserControl which references a StaticResource which would normally be referenced in app.xaml and be fine... but my assembly is a library project so has no app.xaml. How do i reference this StaticResource now?
Here is the UserControl where I am trying to refence it
<UserControl
d:DataContext="{Binding Source={x:Type main:IViewModel},
Converter={StaticResource viewModelLocator}}">
and here is where it would normally be in app.xaml
<Application xmlns:t="http://schemas.t.com/wpf" xmlns:app="clr-namespace:T.UI">
<Application.Resources>
<t:ViewModelLocator
x:Key="viewModelLocator"
Container="{x:Static app:ConfigurationPlugin.Container}" />
</Application.Resources>
I just get the error message "viewModelLocator could not be resolved".
adding the resource to the UserControl's resources itself should do the trick; in fact pretty much every Wpf element has a Resources
property.
<UserControl.Resources>
<t:ViewModelLocator x:Key="viewModelLocator"
Container="{x:Static app:ConfigurationPlugin.Container}" />
</UserControl.Resources>