Inheritance: System.Windows.Controls.TreeViewItem
Exemple #1
0
        public static UmbracoTreeViewItem CreateTreeViewItemWithImageAndTooltip(string name, string imageName, bool showExpander, string toolTip)
        {
            var stackpanel = new StackPanel {
                Orientation = Orientation.Horizontal, Margin = new System.Windows.Thickness(2)
            };

            stackpanel.Children.Add(ImageHelper.GetImageFromResource(imageName));
            stackpanel.Children.Add(new TextBlock {
                Text = " " + name
            });

            var databaseTreeViewItem = new UmbracoTreeViewItem {
                Header = stackpanel, MetaData = name
            };

            databaseTreeViewItem.MouseRightButtonDown += DatabaseTreeViewItemMouseRightButtonDown;
            databaseTreeViewItem.ContextMenu           = new ContextMenu {
                Visibility = Visibility.Hidden
            };
            if (!string.IsNullOrWhiteSpace(toolTip))
            {
                databaseTreeViewItem.ToolTip = toolTip;
            }
            if (showExpander)
            {
                databaseTreeViewItem.Items.Add("Loading...");
            }
            return(databaseTreeViewItem);
        }
        public static UmbracoTreeViewItem CreateTreeViewItemWithImage(string name, string imageName, bool showExpander)
        {
            var stackpanel = new StackPanel { Orientation = Orientation.Horizontal, Margin = new System.Windows.Thickness(2) };
            stackpanel.Children.Add(ImageHelper.GetImageFromResource(imageName));
            stackpanel.Children.Add(new TextBlock { Text = " " + name });

            var databaseTreeViewItem = new UmbracoTreeViewItem { Header = stackpanel, MetaData = name };
            databaseTreeViewItem.MouseRightButtonDown += DatabaseTreeViewItemMouseRightButtonDown;
            databaseTreeViewItem.ContextMenu = new ContextMenu { Visibility = Visibility.Hidden };
            if (showExpander) databaseTreeViewItem.Items.Add("Loading...");
            return databaseTreeViewItem;
        }
 private void FillNodeItems(KeyValuePair<string, string> tree, UmbracoTreeViewItem parentItem)
 {
     parentItem.Items.Clear();
     var nodes = UmbracoApplicationContext.Current.GetChildrenByType(tree.Key, parentItem.NodeId);
     foreach (var node in nodes)
     {
         var children = UmbracoApplicationContext.Current.GetChildrenByType(tree.Key, node.Key);
         var item = TreeViewHelper.CreateTreeViewItemWithImage(node.Value["Name"], "../Resources/doc2.gif", children.Any());
         item.NodeId = node.Key;
         item.Expanded += (sender, args) => new GetNodeItemsHandler(GetNodeItems).BeginInvoke(sender, args, tree, null, null);
         parentItem.Items.Add(item);
     }
 }