当前位置: 首页>>代码示例>>C#>>正文


C# TreeViewItem.ExpandSubtree方法代码示例

本文整理汇总了C#中System.Windows.Controls.TreeViewItem.ExpandSubtree方法的典型用法代码示例。如果您正苦于以下问题:C# TreeViewItem.ExpandSubtree方法的具体用法?C# TreeViewItem.ExpandSubtree怎么用?C# TreeViewItem.ExpandSubtree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Controls.TreeViewItem的用法示例。


在下文中一共展示了TreeViewItem.ExpandSubtree方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MainWindow

        public MainWindow(ICatalogManager catMgr, IFinancialManager finMgr)
        {
            InitializeComponent();

            _catMgr = catMgr;
            _finMgr = finMgr;

            var root = new TreeViewItem();
            root.Header = "Tree";

            var child = new TreeViewItem();
            child.Header = "Initial Data Typing";
            root.Items.Add(child);

            child = new TreeViewItem();
            child.Header = "Descriptions";
            root.Items.Add(child);

            MainTreeView.Items.Add(root);

            root.ExpandSubtree();

            AreaComboBox.AddHandler(TextBoxBase.TextChangedEvent,
                new TextChangedEventHandler(ComboBox_TextChanged));
        }
开发者ID:cleverxy,项目名称:csharp,代码行数:25,代码来源:MainWindow.xaml.cs

示例2: ToTreeViewItem

 public static TreeViewItem ToTreeViewItem(this ProjectModel project)
 {
     var node = new TreeViewItem { Header = project.Name };
     if (!project.AllChildrenExist)
         node.ExpandSubtree();
     return node;
 }
开发者ID:Mozketo,项目名称:AccurateReferences,代码行数:7,代码来源:ModelExtensions.cs

示例3: button_Click

        //private static void ProcessNode(HtmlNode node, Stack<HtmlNode> stack)
        //{
        //    var depth = stack.Count;
        //    var padding = String.Empty.PadLeft(depth, ' ');
        //    stack.Push(node);
        //    try
        //    {
        //        Debug.WriteLine(padding + "Node: " + node.Name);
        //        foreach (var child in node.ChildNodes)
        //        {
        //            ProcessNode(child, stack);
        //        }
        //    }
        //    finally
        //    {
        //        stack.Pop();
        //    }
        //}

        private void button_Click(object sender, RoutedEventArgs e)
        {
            using (var stream = File.OpenRead(@"C:\Documents\bookmarks_7_27_15.html"))
            {
                var doc = new HtmlDocument();
                doc.Load(stream);

                var rootFolder = new Folder { Name = "<root>" };

                ProcessNode(doc.DocumentNode, rootFolder);
                if (rootFolder.Folders.Count == 1)
                    rootFolder = rootFolder.Folders.Single();

                treeView.Items.Add(GetTree(rootFolder));

                var bookmarks = rootFolder.AllBookmarks.ToList();
                bookmarks.Sort(
                    (l, r) => StringComparer.OrdinalIgnoreCase.Compare(l.Href.ToString(), r.Href.ToString()));
                var lookupItem = new TreeViewItem { Header = "Lookup" };
                var lookup = rootFolder.AllBookmarks.ToLookup(b => b.Href.ToString(), b => b.Folder, StringComparer.OrdinalIgnoreCase);
                foreach (var key in lookup)
                {
                    var folders = new HashSet<string>(key.Select(k => k.FullName), StringComparer.OrdinalIgnoreCase);
                    if (folders.Count > 1)
                    {
                        //folders.Sort((l, r) => StringComparer.OrdinalIgnoreCase.Compare(l.FullName, r.FullName));
                        var keyItem = new TreeViewItem { Header = key.Key + " (" + folders.Count + ")" };
                        foreach (var folder in folders.OrderBy(f => f, StringComparer.OrdinalIgnoreCase))
                            keyItem.Items.Add(new TreeViewItem { Header = folder });
                        lookupItem.Items.Add(keyItem);
                    }
                }
                lookupItem.ExpandSubtree();
                treeView.Items.Add(lookupItem);
                var set = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
                foreach (var bookmark in rootFolder.AllBookmarks)
                    set.Add(bookmark.ToString());
                foreach (var txt in set)
                    Debug.WriteLine(txt);

                using (var output = File.OpenWrite(@"C:\Documents\output.html"))
                {
                    output.SetLength(0);
                    using (var writer = new StreamWriter(output))
                    {

                        writer.WriteLine(@"<!DOCTYPE NETSCAPE-Bookmark-file-1>");
                        writer.WriteLine(@"<!-- This is an automatically generated file.");
                        writer.WriteLine(@"     It will be read and overwritten.");
                        writer.WriteLine(@"     DO NOT EDIT! -->");
                        writer.WriteLine(
                            "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html;charset=UTF-8\">");
                        writer.WriteLine(@"<TITLE>Bookmarks</TITLE>");
                        WriteFolder(rootFolder, writer, new HashSet<string>(StringComparer.OrdinalIgnoreCase), "");
                    }
                }

                //Debugger.Break();
            }
        }
开发者ID:zeldafreak,项目名称:Area51,代码行数:79,代码来源:MainWindow.xaml.cs

示例4: MainWindow

        public MainWindow(ICatalogManager catMgr, IFinancialManager finMgr)
        {
            InitializeComponent();

            _catMgr = catMgr;
            _finMgr = finMgr;

            var root = new TreeViewItem();
            root.Header = "Tree";

            var child = new TreeViewItem();
            child.Header = "Initial Data Typing";
            child.Selected += TreeViewItemSelected;
            child.Tag = typeof(InitialDataTypingView);
            root.Items.Add(child);

            child = new TreeViewItem();
            child.Header = "Descriptions";
            child.Selected += TreeViewItemSelected;
            child.Tag = typeof(DescriptionView);
            root.Items.Add(child);

            MainTreeView.Items.Add(root);

            root.ExpandSubtree();
        }
开发者ID:cleverxy,项目名称:csharp,代码行数:26,代码来源:MainWindow.xaml.cs

示例5: AddLayer

        private void AddLayer(Layer layer)
        {
            Type layerClassType = layer.GetType();

            TreeViewItem newItem = new TreeViewItem();
            newItem.Header = Layer.LayerTypes[layerClassType];
            newItem.Tag = layer;
            foreach (var p in layerClassType.GetProperties())
            {
                var property = p;   // we want to closure this value in lambdas - therefore there must be an additional variable - do not use the foreach variable p!
                LayerAttributes.LayerAttribute[] layerAttributeList = (LayerAttributes.LayerAttribute[])
                                        property.GetCustomAttributes(typeof(LayerAttributes.LayerAttribute), false);
                if (layerAttributeList.Length > 0)
                {
                    // create ui for this element
                    layerAttributeList[0].CreateTreeViewSubElement(newItem, (int)Layers.ActualWidth,
                                () => { return property.GetMethod.Invoke(layer, new object[0]); },
                                (value) => { property.SetMethod.Invoke(layer, new object[] { value }); });

                    // pointset layer must be registered
                    if (layerAttributeList[0] is LayerAttributes.LayerAttributePointSet)
                        terrainRenderingPreview.AddPointSet((PointSet)property.GetMethod.Invoke(layer, new object[0]));
                }
            }
            if (Layers.Items.IsEmpty || (Layers.SelectedItem == null))
                Layers.Items.Insert(0, newItem);
            else
                Layers.Items.Insert(Layers.Items.IndexOf(Layers.SelectedItem), newItem);
            newItem.ExpandSubtree();
            newItem.IsSelected = true;
        }
开发者ID:Wumpf,项目名称:mstbasedheightmapgen,代码行数:31,代码来源:LayerPanel.cs

示例6: ShowObject

        public void ShowObject(BsonValue bsonValue)
        {
            var tree = new TreeView();

            var item = new TreeViewItem();
            tree.Items.Add(item);
            WriteObject(item, bsonValue);
            item.ExpandSubtree();
            this.Content = tree;
            Show();
            Focus();
            this.Topmost= true;
        }
开发者ID:kulalexey,项目名称:PrettyLog,代码行数:13,代码来源:ShowObjectWindow.xaml.cs

示例7: ExceptionMessageBox

        public ExceptionMessageBox(System.Exception e, string userExceptionMessage)
        {
            InitializeComponent();

            this._userExceptionMessage = userExceptionMessage;
            textBox1.Text = userExceptionMessage;

            TreeViewItem treeViewItem = new TreeViewItem();
            treeViewItem.Header = "Exception";
            treeViewItem.ExpandSubtree();
            buildTreeLayer(e, treeViewItem);
            treeView1.Items.Add(treeViewItem);
        }
开发者ID:AlternateIf,项目名称:huddle-engine,代码行数:13,代码来源:ExceptionMessageBox.xaml.cs

示例8: MainWindow

        public MainWindow()
        {
            InitializeComponent();

            var root = new TreeViewItem();
            root.Header = "Tree";

            var child = new TreeViewItem();
            child.Header = "Initial Data Typing";
            root.Items.Add(child);

            child = new TreeViewItem();
            child.Header = "Descriptions";
            root.Items.Add(child);

            MainTreeView.Items.Add(root);

            root.ExpandSubtree();
        }
开发者ID:cleverxy,项目名称:csharp,代码行数:19,代码来源:MainWindow.xaml.cs

示例9: ExplanationView

        public ExplanationView(IEnumerable<AutoCompletionResult.CommandResult> commandResults)
        {
            InitializeComponent();

            foreach (var commandResult in commandResults)
            {
                var commandTreeItem = new TreeViewItem {Header = commandResult.Item.Text + commandResult.CompletionId};
                Action<TreeViewItem, Explanation> renderExplanation = null;
                renderExplanation = (t, exp) =>
                                        {
                                            var header = exp.Value + " " + exp.Description + " ";
                                            var childItem = new TreeViewItem {Header = header};
                                            t.Items.Add(childItem);
                                            foreach (var explanation in exp.GetDetails() ?? new Explanation[] {})
                                            {
                                                renderExplanation(childItem, explanation);
                                            }
                                        };
                renderExplanation(commandTreeItem, commandResult.Explanation);
                commandTreeItem.ExpandSubtree();
                ExplanationTree.Items.Add(commandTreeItem);
            }
        }
开发者ID:brunomlopes,项目名称:ILoveLucene,代码行数:23,代码来源:ExplanationView.xaml.cs

示例10: MainWindow

        public MainWindow(ICatalogManager catMgr)
        {
            InitializeComponent();

            _catMgr = catMgr;

            var root = new TreeViewItem();
            root.Header = "Tree";

            var child = CreateTreeViewItem("Initial Data Typing");
            child.Tag = typeof(InitialDataTypingForm);
            root.Items.Add(child);

            child = CreateTreeViewItem("Descriptions");
            child.Tag = typeof(DescriptionsForm);
            root.Items.Add(child);

            MainTreeView.Items.Add(root);

            root.ExpandSubtree();

            AreaComboBox.AddHandler(TextBoxBase.TextChangedEvent,
                new TextChangedEventHandler(ComboBox_TextChanged));
        }
开发者ID:cleverxy,项目名称:csharp,代码行数:24,代码来源:MainWindow.xaml.cs

示例11: Group

        void Group()
        {
            GroupTree.Items.Clear();
            Results.Visibility = Visibility.Collapsed;
            GroupTree.Visibility = Visibility.Visible;

            if (Query.Text == string.Empty || DataToQuery.Text == string.Empty)
                return;

            try
            {
                Regex theExpr;

                try
                {
                    theExpr = new Regex(Query.Text, RegExOptions, Timeout);
                }
                catch (RegexMatchTimeoutException)
                {
                    Status.Content = QueryTime.Content = "Timeout";
                    return;
                }
                catch (Exception E)
                {
                    Status.Content = E.Message;
                    return;
                }

                var c = theExpr.Matches(DataToQuery.Text);

                foreach (Match match in c)
                {
                    var header = new TreeViewItem { Header = match.Value };

                    foreach (var groupName in theExpr.GetGroupNames())
                    {
                        var theGroup = match.Groups[groupName];

                        if (groupName == "0")
                            continue;

                        var groupHeader = new TreeViewItem { Header = "<" + groupName + "> " + theGroup };
                        header.Items.Add(groupHeader);

                        foreach (Capture theCapture in theGroup.Captures)
                            groupHeader.Items.Add(theCapture.Value);
                    }

                    GroupTree.Items.Add(header);
                    header.ExpandSubtree();
                }

                Status.Content = c.Count == 0 ? "No Matches" : "Matched";
            }
            catch (Exception e) { Status.Content = e.Message; }
        }
开发者ID:MathewSachin,项目名称:RegX,代码行数:56,代码来源:MainWindow.xaml.cs

示例12: Setup


//.........这里部分代码省略.........
                                        if (!(cursor is TreeViewItem))
                                        {
                                            Controller.saved_repository = ((SelectionTreeItem)treeViewItem.Tag).repository;
                                        }
                                    }

                                    // Load sub-folders if it has not been done already.
                                    // We use each item's Tag to store metadata: whether this item's subfolders have been loaded or not.
                                    if (((SelectionTreeItem)item.Tag).childrenLoaded == false)
                                    {
                                        System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;

                                        // Get list of subfolders (asynchronously)
                                        GetSubfoldersDelegate dlgt = new GetSubfoldersDelegate(CmisUtils.GetSubfolders);
                                        IAsyncResult ar = dlgt.BeginInvoke(Controller.saved_repository,
                                            Controller.saved_remote_path, Controller.saved_address.ToString(),
                                            Controller.saved_user, Controller.saved_password, null, null);
                                        while (!ar.AsyncWaitHandle.WaitOne(100))
                                        {
                                            System.Windows.Forms.Application.DoEvents();
                                        }
                                        string[] subfolders = dlgt.EndInvoke(ar);

                                        // Create a sub-item for each subfolder
                                        foreach (string subfolder in subfolders)
                                        {
                                            System.Windows.Controls.TreeViewItem subItem =
                                                new System.Windows.Controls.TreeViewItem();
                                            subItem.Tag = new SelectionTreeItem(null, subfolder);
                                            subItem.Header = Path.GetFileName(subfolder);
                                            item.Items.Add(subItem);
                                        }
                                        ((SelectionTreeItem)item.Tag).childrenLoaded = true;
                                        item.ExpandSubtree();
                                        System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
                                    }
                                };

                                Button cancel_button = new Button()
                                {
                                    Content = Properties_Resources.Cancel
                                };

                                Button continue_button = new Button()
                                {
                                    Content = CmisSync.Properties_Resources.ResourceManager.GetString("Continue", CultureInfo.CurrentCulture)
                                };

                                Button back_button = new Button()
                                {
                                    Content = Properties_Resources.Back,
                                    IsDefault = false
                                };

                                Buttons.Add(back_button);
                                Buttons.Add(continue_button);
                                Buttons.Add(cancel_button);

                                continue_button.Focus();

                                cancel_button.Click += delegate
                                {
                                    Controller.PageCancelled();
                                };

                                continue_button.Click += delegate
开发者ID:prignony,项目名称:CmisSync,代码行数:67,代码来源:Setup.cs

示例13: SparkleSetup


//.........这里部分代码省略.........

                            // Identify the selected repository.
                            object cursor = item;
                            while (cursor is TreeViewItem)
                            {
                                TreeViewItem treeViewItem = (TreeViewItem)cursor;
                                cursor = treeViewItem.Parent;
                                if ( ! (cursor is TreeViewItem))
                                {
                                    Controller.saved_repository = (string)treeViewItem.Header;
                                }
                            }

                            // Load sub-folders if it has not been done already.
                            // We use each item's Tag to store metadata: whether this item's subfolders have been loaded or not.
                            if ( ((SelectionTreeItem)item.Tag).childrenLoaded == false)
                            {
                                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;

                                // Get list of subfolders
                                string[] subfolders = CmisUtils.GetSubfolders(Controller.saved_repository, Controller.saved_remote_path,
                                    Controller.saved_address, Controller.saved_user, Controller.saved_password);

                                // Create a sub-item for each subfolder
                                foreach (string subfolder in subfolders)
                                {
                                    System.Windows.Controls.TreeViewItem subItem =
                                        new System.Windows.Controls.TreeViewItem();
                                    subItem.Tag = new SelectionTreeItem(subfolder);
                                    subItem.Header = Path.GetFileName(subfolder);
                                    item.Items.Add(subItem);
                                }
                                ((SelectionTreeItem)item.Tag).childrenLoaded = true;
                                item.ExpandSubtree();
                                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
                            }
                        };

                        Button cancel_button = new Button()
                        {
                            Content = "Cancel"
                        };

                        Button add_button = new Button()
                        {
                            Content = "Add"
                        };

                        Buttons.Add(add_button);
                        Buttons.Add(cancel_button);

                        cancel_button.Click += delegate
                        {
                            Controller.PageCancelled();
                        };

                        add_button.Click += delegate
                        {
                            Controller.Add2PageCompleted(
                                Controller.saved_repository, Controller.saved_remote_path);
                        };

                        break;
                    }

                    case PageType.Syncing: {
开发者ID:smcardle,项目名称:CmisSync,代码行数:67,代码来源:SparkleSetup.cs

示例14: UpdateCacheView

		private void UpdateCacheView()
		{
			cacheDirectoryTextBox.Text = Cache.CacheDirectory;

			cacheTreeView.Items.Clear();

			//show error if cache not detected
			if (!File.Exists(Cache.CacheDirectory + Cache.CacheFileName))
			{
				cacheTreeView.Items.Add("No cache file found in directory.");
				_canExtract = false;
				return;
			}

			//fill the treeview
			var cacheTreeItem = new TreeViewItem
			{
				Header = "Cache",
				Tag = -1,
				ContextMenu = (ContextMenu)Resources["ExtractContextMenu"]
			};
			cacheTreeItem.MouseDoubleClick += cacheTreeViewItem_DoubleClick;

			cacheTreeItem.ExpandSubtree();

			foreach (var archiveId in Cache.GetArchiveIds())
			{
				var archiveTreeItem = new TreeViewItem
				{
					Header = $"Archive {archiveId}",
					Tag = archiveId,
					ContextMenu = (ContextMenu)Resources["ExtractContextMenu"]
				};

				archiveTreeItem.MouseDoubleClick += cacheTreeViewItem_DoubleClick;

				cacheTreeItem.Items.Add(archiveTreeItem);
			}

			_canExtract = true;
			cacheTreeView.Items.Add(cacheTreeItem);
		}
开发者ID:Vishrs,项目名称:RuneScapeCacheTools,代码行数:42,代码来源:MainWindow.xaml.cs

示例15: ShowFormula

        private void ShowFormula(string cellRef, string formula)
        {
            var formulaObject = new ExcelFormulaParser.ExcelFormula(formula);
            System.Action action = () =>
            {
                FormulaTreeView.Items.Clear();
                var rootItem = new TreeViewItem {Header = cellRef};
                FormulaTreeView.Items.Add(rootItem);
                ShowFormula(new Queue<ExcelFormulaToken>(formulaObject), rootItem.Items);
                rootItem.ExpandSubtree();
            };

            Dispatcher.BeginInvoke(action);
        }
开发者ID:adamgoral,项目名称:ML,代码行数:14,代码来源:FormulaExplorer.xaml.cs


注:本文中的System.Windows.Controls.TreeViewItem.ExpandSubtree方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。