Peter
Peter

Reputation: 1715

Bind Treeview to data structure

I have the following class definition where I want to bind it to a Treeview in WPF if possible. Not sure where to start on this one. Any clues?

public class DirectoryTree
{
    public String Name {get; set;}

    public String FullPath { get; set; }

    public List<DirectoryTree> Children { get; set; }

}

Upvotes: 0

Views: 927

Answers (1)

Y.Yanavichus
Y.Yanavichus

Reputation: 2417

It's all right with your code. All you need is to define HierarchicalDataTemplate for TreeView and may be add two properties to DirectoryTree - IsSelected and IsExpanded - using INotifyPropertyChanged.

Upvotes: 1

Related Questions