Change arrows color in TreeView

Posted by: firelex on 4 July 2021, 11:26 pm EST

    • Post Options:
    • Link

    Posted 4 July 2021, 11:26 pm EST

    I’m using C1TreeView from the C1 examples (SimpleC1TreeViewPage).

    When not selected TreeItem and its arrow are dark blue - both good visible on gray background. But on selection happens following:

    • "

    • “background gets dark blue”

    • “TreeItem is painted white - still visible”

    • “arrow remains dark blue - gets invisible!”

    "

    How can change color of arrows (collapsed and expanded) in TreeView when the item is selected?

    Thanks in advance.

  • Posted 6 July 2021, 12:01 am EST

    Hi Lex,

    You can implement this requirement by using DataTrigger with ToggleButton’s (present in TreeViewItem template) ControlTemplate as follows:

    
    <ControlTemplate.Triggers>
                  <DataTrigger Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type c1:C1TreeViewItem}}, Path=IsSelected}" Value="True">
                            <Setter TargetName="CollapsedIcon" Property="Fill" Value="Red"/>
                            <Setter TargetName="ExpandedIcon" Property="Fill" Value="Red"/>
                   </DataTrigger>
    </ControlTemplate.Triggers>
    
    

    Please refer to the same from the attached modified sample. (see BasicControls_Mod.zip)

    Best Regards,

    Kartik

    BasicControls_Mod.zip

  • Posted 6 July 2021, 6:21 pm EST

    Thanks, Kartik!

    Just what I needed.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels