I work with C# WPF TreeView.
I have folowing input data: (like 1000+ lines that I need to process)
\Folder\Base\Data\dat.cfg
\Folder\Base\Data1\dat.cfg
\Folder\dat.cfg
Collection class - TreeItem. Used for TreView binding.
public class TreeItem : MyViewModel
{
public TreeItem()
{
this.Children = new ObservableCollection<TreeItem>();
}
public string Name { get; set; }
public ObservableCollection<TreeItem> Children { get; set; }
}
I'm spending on this fews days and I'm not able to figure out algorithm how to obtain data to requested point.
Please I would really appreciate if somebody could give me help or just way how to achieve it.
Thank you in advance.
This is my class for collection
I need to acomplish input data to be parsed as following in my defined collection class - TreeItem. Basicaly just to be working in TreeView as nodes with levels.
CollectionTreeItem
[0] Name - "Folder"
Children
[0] Name - "Base"
Children
[0] Name - "Data"
Children
[0] Name - "dat.cfg"
Children
Only example with procesed line - \Folder\Base\Data\dat.cfg. Of course there will be more child with another lines.
You could use a recursive algorithm to build the tree.
treeObjectsshould hold the structure you're trying to achieve.