public void tryExpand(ItemCollection rootCollection, string name, bool select = false) { //loop through the items and try and expand / populate the item if one exists foreach (TreeViewItem i in rootCollection) { if (i.Header.ToString().ToUpper() == name.ToUpper()) { if (select) { i.IsSelected = true; SetSelected(FolderBrowser, i); } else { i.IsExpanded = true; } } //if it is just our "loading.." message, drop out if (!((i.Items.Count == 1) && (i.Items[0] is string))) { tryExpand(i.Items, name, select); } } FolderBrowser.UpdateLayout(); }