private void TreeViewItem_MouseClick(object sender, MouseButtonEventArgs e) { ItemTemplateControl.Visibility = Visibility.Hidden; FolderTemplateControl.Visibility = Visibility.Hidden; var tvit = sender as StackPanel; var item = tvit.DataContext as Item; if (item != null) { var detailedItem = LinqToSitecoreFactory.GetItem(item.Id); var templateItem = LinqToSitecoreFactory.GetItem(detailedItem.TemplateKey == "template" ? detailedItem.Id : detailedItem.TemplateId); var items = LinqToSitecoreFactory.GetChildren(item.Id); item.Children.Clear(); foreach (var i in items) { item.Children.Add(i); } item.IsExpanded = true; if (templateItem != null) { templateItem.Namespace = LinqToSitecoreFactory.ProjectNamespace; item.Namespace = LinqToSitecoreFactory.ProjectNamespace; ItemTemplateControl.DataContext = templateItem; ItemTemplateControl.Visibility = Visibility.Visible; } } }
private void GetRoot() { var root = LinqToSitecoreFactory.GetChildren(SitecoreGuids.Root); SitecoreItemsTree.ItemsSource = new ObservableCollection <Item>(root); }