I'm trying to fire a trigger when a property in my ViewModel changes. I can't seem to get the trigger to fire no matter what I try. My XAML looks like this:
<TreeView.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
<Setter Property="Padding" Value="0 1" />
<Setter Property="FontWeight" Value="Normal" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsExpanding}" Value="True">
<Setter Property="Control.Template" Value="{StaticResource ResourceKey=loadingTreeViewItem}" />
</DataTrigger >
<Trigger Property="IsSelected" Value="True">
<Setter Property="FontWeight" Value="Bold" />
</Trigger>
</Style.Triggers>
</Style>
The IsExpanded and IsSelected bindings are working fine, however I can't get the DataTrigger to fire when IsExpanding is true. These properties are in the same ViewModel. I have tried adding different variations for RelativeSource but am not having any luck. Any 开发者_开发知识库feedback is appreciated.
Turns out the trigger was working. The problem was that the IsExpanding property and the call to get the data for the TreeView were both happening on the UI thread. I threaded the call to get the data and everything is working as expected
精彩评论