Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Treeview with "unlimited" sub-nodes

$
0
0

Hi.

the previous project i worked on and asked little about here went fine.

Now they want to be able to put  more or less "unlimited" sub-nodes in the treeview.

The source data would come in this format

Stockholm\Södertälje;101;Hovsjö;digital2;
Stockholm\Södertälje;102;Geneta;digital3;
Stockholm\Kungens Kurva;101;Lindvreten;digtal1;
Stockholm\Kungens Kurva;102;Lindvretsbacken;digtal4;

Where "Stockholm\Södertälje" is the root\subNode\Subnode format.
The Hovsjö, Geneta, Lindvreten, Lindvretsbacken is the items that will updates using the information in the OPC tag digital[1-4]

I have tried a few ways to add all the roots and sub-nodes in the right way, but i have yet to achieve the goal to produce several sub-sub-nodes

Do anyone have any tips how i could go about to add several subnodes into each others using the source data above?

Each node is a copy of this class

    public class Thing : INotifyPropertyChanged
    {
        private SolidColorBrush _statusBrush;
        public SolidColorBrush StatusBrush
        {
            get { return _statusBrush; }
            set { _statusBrush = value; NotifyPropertyChanged("StatusBrush"); }
        }

        private string _name;
        public string Name
        {
            get { return _name; }
            set { _name = value; NotifyPropertyChanged("Name"); }
        }

        private string _tag;
        public string Tag
        {
            get { return _tag; }
            set { _tag = value; NotifyPropertyChanged("Tag"); }
        }

        private string _status;
        public string Status
        {
            get { return _status; }
            set { _status = value; NotifyPropertyChanged("Status"); }
        }


        private string _parentnode;
        public string ParentNode
        {
            get { return _parentnode; }
            set { _parentnode = value; NotifyPropertyChanged("ParentNode"); }
        }

        public ObservableCollection<Thing> Children { get; set; }


        #region INotifyPropertyChanged
        public event PropertyChangedEventHandler PropertyChanged;
        public void NotifyPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
        #endregion
    }


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>