>Hi,
>I have the following Style defined for TreeViewItem:
<Style TargetType="TreeViewItem" x:Key="StdTreeViewItemStyle">
> <Setter Property="Template">
> <Setter.Value>
> <!-- Standard TreeViewItem ControlTemplate pasted here -->
> </Setter.Value>
> </Setter>
> <Setter Property="IsExpanded" Value="{Binding Path=IsExpanded, Mode=TwoWay}" />
> <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" />
> <Style.Triggers>
> <Trigger Property="IsSelected" Value="True">
> <Setter Property="FontWeight" Value="Bold" />
> <Setter Property="Foreground" Value="Red" />
> </Trigger>
> </Style.Triggers>
> </Style>
Without the Template setter the IsExpanded and IsSelected bindings work fine. With the ControlTemplate in place they no longer work (before I've made any tweaks to the ControlTemplate). FWIW the Trigger *does* work.
>
>UPDATE: FWIW, the TreeView also uses a DataTemplate. This works without the ControlTemplate but with it, although the TemplateSelector is called and returns the relevant DataTemplate, the default template is actually used.......
>
>Any ideas what goes wrong here?
>TIA,
>Viv
I assume the control template you are using actually handles "IsSelected" and "IsExpanded" in the Triggers? (I know, way too obvious, but had to ask.)
One thing I see that is different from the way I write these. I always put the template last and the setters first, you have it template first and the setters last. Does it work if you switch it around? For some reason I think the setters have to exist before the template is defined. No clue why I think that.