public void RefreshCategoryTree() { CategoryTree.BeginInit(); CategoryTree.Items.Clear(); foreach (var pg in SettingsPages) { CategoryTree.Items.Add(_BuildCategoryNode(pg)); } // If nothing selected and page control empty, select first item if (PropPageHost.Content == null && CategoryTree.Items.Count > 0) { SetSettingPage(CategoryTree.Items[0] as TreeViewItem); } CategoryTree.EndInit(); }