private TreeViewToggleItem GetTreeView(string path, bool initialState)
        {
            var item = new TreeViewToggleItem(path, initialState);

            item.Children.Add(new TreeViewToggleItem("Loading Items...", false));
            item.Children = GetSubfolders(item, initialState);
            return(item);
        }
        private List <TreeViewToggleItem> GetSubfolders(TreeViewToggleItem parent, bool initialState)
        {
            var subItems = new List <TreeViewToggleItem>();

            try
            {
                foreach (var path in Directory.GetDirectories(parent.Path))
                {
                    var item = new TreeViewToggleItem(path, initialState, parent);
                    item.Children = GetSubfolders(item, initialState);
                    subItems.Add(item);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }

            return(subItems);
        }