How to use a custom Button instead of ExpanderButton

73 Views Asked by At

I've used the TreeView control for a project and it's been really useful for me! You've saved a lot of hard work, so I wanted to thank you in the first place :)

I need to fill a TreeView using a custom UserControl which, among other fields, has a button that must perform as the ExpanderButton.

Here's the DataTemplate from which the TreeView page is filled:

  <DataTemplate
                    x:Key="TreeViewItemTemplate">
                    <data:DataTemplateExtensions.Hierarchy>
                        <data:HierarchicalDataTemplate
                            ItemsSource="{Binding Children}" />
                    </data:DataTemplateExtensions.Hierarchy>

                    <Grid>
                        <components:VideoSessions Title="{Binding Title}"
                                                  Start="{Binding Start}"
                                                  End="{Binding End}"
                                                  Status="{Binding Status}"
                                                  HasHighlights="{Binding HasHighlights}"/>
                    </Grid>

</DataTemplate>

How could I bind the behavior of the ExpanderButton to my control? Thanks in advance!

1

There are 1 best solutions below

0
On BEST ANSWER

The TreeView control has an IsExpandedBindingPath property (as used in here) that you could use to bind the expanded state of the TreeViewItems to your backing tree node models. You could then TwoWay-bind the toggle state of your ExpanderButton to that same property on the tree node model.