Search code examples
wpftriggerstreeviewstylesexpander

Style expander buttons of TreeView


Here is my XAML:

            <Style x:Key="ExpanderStyle" TargetType="{x:Type ToggleButton}">
            <Setter Property="IsEnabled" Value="True" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Image Source="/Images/SHCalendarLeftArrow.tiff" />
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

So what I want is so that if the item is expanded, then display a different image.


Solution

  • Nevermind. I used a trigger

    <Trigger Property="ToggleButton.IsChecked" Value="False">
                                <Setter x:Name="Expander_Expanded"
                                        TargetName="Expander_Normal" Property="Source"
                                        Value="/Images/SHCalendarLeftArrow.tiff" />
                            </Trigger>