Reputation: 43
I would like to bind to a Property ShowHat
which is within a ViewModel
called "HatViewModel" from Application.Resources
.
I can obtain access to the ViewModel
via a namespace like so:
xmlns:vm="clr-namespace:HatApp.ViewModels
<Application.Resources>
<vm:HatViewModel x:Key="HatVM"/>
</Application.Resources>
But when I try to use the ViewModel's Property in a binding, it does not work.
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding HatVM.ShowHat}" Value="True">
<Setter Property="IsEnabled" Value="False"/>
</DataTrigger>
</ControlTemplate.Triggers>
Any help is greatly appreciated.
Upvotes: 1
Views: 254
Reputation: 843
You should use Source
when you trying to bind a property from a static resource:
<DataTrigger Binding="{Binding ShowHat, Source={StaticResource HatVM}}" Value="True">
Upvotes: 1