Georgiana M
Georgiana M

Reputation: 431

How to expand Treeview until certain node?

I want be able to expand certain node in a WPF TreeView tree. The tree items are contained in an ObservableCollection list.

Upvotes: 0

Views: 447

Answers (1)

Abin
Abin

Reputation: 2956

TreeViewItem has a property IsExpanded you can bind the property with your ObservableCollection object property and handle it from your ViewModel.

        <Style TargetType="{x:Type TreeViewItem}">
            <Setter Property="IsExpanded" Value="{Binding IsExpandedProp}" />                
        </Style> 

ViewModel

 public bool IsExpandedProp
    {
        get { return _IsExpandedProp; }
        set { _Values = _IsExpandedProp; NotifyPropertyChanged(); }
    }

Upvotes: 1

Related Questions