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


C# Controls.TreeView类代码示例

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


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

示例1: GetTreeViewItemFromPoint

 // Static Methods
 private static TreeViewItem GetTreeViewItemFromPoint(TreeView treeView, Point point)
 {
     DependencyObject obj = treeView.InputHitTest(point) as DependencyObject;
     while (obj != null && !(obj is TreeViewItem))
         obj = VisualTreeHelper.GetParent(obj);
     return obj as TreeViewItem;
 }
开发者ID:Stranho,项目名称:bgda-explorer,代码行数:8,代码来源:FileTreeViewContextManager.cs

示例2: loadCompany

        private void loadCompany() {
            TreeView treeView = new TreeView();


            foreach (Company companyItem in companies) {
                TreeViewItem treeViewItem = new TreeViewItem { Name = companyItem.Username, Header = companyItem.Username + " (" + companyItem.Trackers.Count.ToString() + ")", Background = Brushes.AliceBlue };

                if (companyItem.Trackers == null)
                    continue;

                foreach (Tracker tracker in companyItem.Trackers) {
                    TreeViewItem treeViewSubItem = new TreeViewItem { Name = "tracker" + tracker.TrackerImei, Header = tracker.TrackerImei };
                    treeViewItem.Items.Add(treeViewSubItem);
                }

                treeView.Items.Add(treeViewItem);
            }

            TabItem tabPage = new TabItem();

            tabPage.Header = "Companies";
            tabPage.Content = treeView;

            foreach (TabItem tabItem in tabControl.Items) {
                if (tabItem.Header == tabPage.Header) {
                    tabControl.Items.Remove(tabItem);
                    break;
                }
            }

            tabControl.Items.Add(tabPage);
        }
开发者ID:rhalf,项目名称:AtsTqatPro,代码行数:32,代码来源:FormMain.xaml.cs

示例3: WalkTreeViewItem

        public static bool WalkTreeViewItem(TreeView tree, TreeViewItem treeViewItem, object selectedValue)
        {
            if (treeViewItem.DataContext == selectedValue)
            {
                treeViewItem.SetValue(TreeViewItem.IsSelectedProperty, true);
                treeViewItem.Focus();
                treeViewItem.BringIntoView();
                return true;
            }
            var itemsHostProperty = treeViewItem.GetType().GetProperty("ItemsHost", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);

            var itemsHost = itemsHostProperty?.GetValue(treeViewItem, null) as Panel;

            if (itemsHost == null)
            {
                return false;
            }

            foreach (var item in itemsHost.Children.OfType<TreeViewItem>())
            {
                var oldExpanded = item.IsExpanded;
                item.IsExpanded = true;
                item.UpdateLayout();
                if (WalkTreeViewItem(tree, item, selectedValue))
                {
                    return true;
                }
                item.IsExpanded = oldExpanded;
            }

            return false;
        }
开发者ID:AnchoretTeam,项目名称:AppUpdate,代码行数:32,代码来源:BindableSelectedItemHelper.cs

示例4: BuildDockingLayout

        void BuildDockingLayout()
        {
            dockManager.Content = null;

            //TreeView dockable content
            var trv = new TreeView();
            trv.Items.Add(new TreeViewItem() { Header = "Item1" });
            trv.Items.Add(new TreeViewItem() { Header = "Item2" });
            trv.Items.Add(new TreeViewItem() { Header = "Item3" });
            trv.Items.Add(new TreeViewItem() { Header = "Item4" });
            ((TreeViewItem)trv.Items[0]).Items.Add(new TreeViewItem() { Header = "SubItem1" });
            ((TreeViewItem)trv.Items[0]).Items.Add(new TreeViewItem() { Header = "SubItem2" });
            ((TreeViewItem)trv.Items[1]).Items.Add(new TreeViewItem() { Header = "SubItem3" });
            ((TreeViewItem)trv.Items[2]).Items.Add(new TreeViewItem() { Header = "SubItem4" });
            var treeviewContent = new DockableContent() { Title = "Explorer", Content = trv };

            treeviewContent.Show(dockManager, AnchorStyle.Bottom);

            //TextBox invo dockable content
            var treeviewInfoContent = new DockableContent() { Title = "Explorer Info", Content = new TextBox() { Text = "Explorer Info Text", IsReadOnly = true } };
            treeviewContent.ContainerPane.Items.Add(treeviewInfoContent);

            //ListView dockable content
            var gridView = new GridView();
            gridView.Columns.Add(new GridViewColumn() { Header = "Date" });
            gridView.Columns.Add(new GridViewColumn() { Header = "Day Of Weeek", DisplayMemberBinding = new Binding("DayOfWeek") });
            gridView.Columns.Add(new GridViewColumn() { Header = "Year", DisplayMemberBinding = new Binding("Year") });
            gridView.Columns.Add(new GridViewColumn() { Header = "Month", DisplayMemberBinding = new Binding("Month") });
            gridView.Columns.Add(new GridViewColumn() { Header = "Second", DisplayMemberBinding = new Binding("Second") });
            var listView = new ListView() { View = gridView };
            listView.Items.Add(DateTime.Now);
            listView.Items.Add(DateTime.Now.AddYears(-1));
            listView.Items.Add(DateTime.Now.AddMonths(15));
            listView.Items.Add(DateTime.Now.AddHours(354));

            var listViewContent = new DockableContent() { Title = "Date & Times", Content = listView };
            listViewContent.ShowAsFloatingWindow(dockManager, true);

            //TextBox dockable content
            var textboxSampleContent = new DockableContent() { Title = "Date & Times Info", Content = new TextBox() { Text = "Date & Times Info Text", IsReadOnly = true } };
            listViewContent.ContainerPane.Items.Add(textboxSampleContent);

            //DataGrid document
            //var dataGrid = new DataGrid();
            //var rnd = new Random();
            //var data = new List<Tuple<double, double, double, double>>();
            //for (int i = 0; i < 100; i++)
            //{
            //    data.Add(Tuple.Create(rnd.NextDouble(), rnd.NextDouble() * 10.0, rnd.NextDouble() * 100.0, rnd.NextDouble() * 1000.0));
            //}

            //dataGrid.ItemsSource = data;

            //var dataGridDocument = new DocumentContent() { Title = "Data", IsLocked = true, Content = dataGrid };
            //dataGridDocument.Show(dockManager);

            ////DataGrid Info Text sample
            //var dataGridInfoContent = new DockableContent() { Title = "Data Info", Content = new TextBox() { Text = "Data Info Text" } };
            //dataGridInfoContent.ShowAsDocument(dockManager);
        }
开发者ID:JeremyDurnell,项目名称:ChromeTabs,代码行数:60,代码来源:MainWindow.xaml.cs

示例5: Attach

        protected override void Attach()
        {
            _control = ControlObject as TreeView;
            List<TreeViewItem> items = new List<TreeViewItem>();
            HeaderedItemsControlUtility.GetChildren(_control, items);
            foreach (var element in items)
            {
                var item = element;
                string text = HeaderedItemsControlUtility.GetItemText(item);
                if (string.IsNullOrEmpty(text))
                {
                    continue;
                }

                RoutedEventHandler opened = (s, e) =>
                {
                    Expanded(item, new string[] { text });
                };
                item.Expanded += opened;

                RoutedEventHandler click = (s, e) =>
                {
                    SelectedChanged(item, new string[] { text });
                };
                item.Selected += click;
                item.Unselected += click;

                _detach.Add(() =>
                {
                    item.Expanded -= opened;
                    item.Selected -= click;
                    item.Unselected -= click;
                });
            }
        }
开发者ID:Roommetro,项目名称:Friendly.WPFStandardControls,代码行数:35,代码来源:WPFTreeViewGenerator.cs

示例6: switch

 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     this.productTreeView_ = ((System.Windows.Controls.TreeView)(target));
     return;
     case 2:
     
     #line 12 "..\..\..\PositionMaster\NewProductView.xaml"
     ((System.Windows.Controls.TreeViewItem)(target)).Selected += new System.Windows.RoutedEventHandler(this.TreeViewItem_Selected_1);
     
     #line default
     #line hidden
     return;
     case 3:
     
     #line 21 "..\..\..\PositionMaster\NewProductView.xaml"
     ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click);
     
     #line default
     #line hidden
     return;
     }
     this._contentLoaded = true;
 }
开发者ID:minikie,项目名称:OTCDerivativesCalculatorModule,代码行数:25,代码来源:NewProductView.g.cs

示例7: GetTreeViewItem

 /// <summary>
 /// Takes a tree view item and returns the specified item.
 /// </summary>
 /// <param name="tv">The TreeView to search.</param>
 /// <param name="parentName">Name of the parent item in the tree node.  Blank or null if there is no parent.</param>
 /// <param name="itemName"></param>
 /// <returns></returns>
 public static TreeViewItem GetTreeViewItem(TreeView tv, string parentName, string itemName)
 {
     foreach (TreeViewItem tvi in tv.Items)
     {
         if (!String.IsNullOrWhiteSpace(parentName))
         {
             if (tvi.Header.ToString() == parentName)
             {
                 foreach (TreeViewItem tvi_ in tvi.Items)
                 {
                     if (tvi_.Header.ToString() == itemName)
                     {
                         return tvi_;
                     }
                 }
             }
         }
         else
         {
             if (tvi.Header.ToString() == itemName)
             {
                 return tvi;
             }
         }
     }
     return null;
 }
开发者ID:zackLore,项目名称:ZKIT,代码行数:34,代码来源:Utils.cs

示例8: CreateFieldsForSelectedReportType

        /// <summary>
        /// Create TreeView with fields that user can use to create a new object with selected type
        /// </summary>
        public void CreateFieldsForSelectedReportType(object inReportType, TreeView viewElement)
        {
            if (inReportType == null)
            {
                return;
            }

            if (!(inReportType is Type))
            {
                return;
            }

            if (viewElement == null)
            {
                return;
            }

            Type inType = (Type) inReportType;

            viewElement.Items.Clear();

            TreeViewItem newTreeViewItem = new TreeViewItem();
            newTreeViewItem.Header = ((Type)inReportType).Name;
            newTreeViewItem.IsExpanded = true;

            viewElement.Items.Add(newTreeViewItem);

            ConstructTreeWithFields(inType, newTreeViewItem);

        }
开发者ID:sergiytereshchenko,项目名称:BMFNMVVMTest,代码行数:33,代码来源:AddViewModel.cs

示例9: ViewModel

 public ViewModel(Viewport3DX viewport,TreeView _treeview)
 {
     Viewport3D = viewport;
     viewController = new ViewController();
     Model = new Element3DCollection();
     viewController.InitGraphics(Viewport3D, Model,_treeview);
 }
开发者ID:cokemal,项目名称:IfcEngineCS,代码行数:7,代码来源:ViewModel.cs

示例10: Initialize

        public void Initialize(DataUiGrid dataUiGrid, TreeView treeView)
        {
            mDataUiGrid = dataUiGrid;
            mTreeView = treeView;

            FillTreeView();
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:7,代码来源:DataUiGridManager.cs

示例11: GetCurrentUserInstalledPrograms

 public void GetCurrentUserInstalledPrograms(TreeView treeView)
 {
     if (Environment.OSVersion.Version.Major != 10) return;
     var regLocation = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall");
     var installedPrograms = regLocation.GetSubKeyNames().Select(programName => regLocation.OpenSubKey(programName)).Select(subKey => subKey.GetValue("DisplayName").ToString()).ToList();
     DocumentsToTree(treeView, installedPrograms, "Current User Programs");
 }
开发者ID:jsysenkham,项目名称:TechTools,代码行数:7,代码来源:DesiredFiles.cs

示例12: ClearSelection

 public static void ClearSelection(TreeView tree)
 {
     foreach (TreeViewItem selectedItem in GetTreeViewItems(tree))
     {
         selectedItem.SetValue(IsSelectedProperty, false);
     }
     NotifySelectionChangedListeners(tree);
 }
开发者ID:punker76,项目名称:sjupdater,代码行数:8,代码来源:TreeViewExtensions.cs

示例13: OnApplyTemplate

        /// <summary>
        /// テンプレート適用時の処理
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            this.MainTree = this.Template.FindName(PART_MainTree, this) as TreeView;

            Initilization();
        }
开发者ID:YKSoftware,项目名称:YKToolkit.Controls,代码行数:11,代码来源:Generic.FileTreeView.xaml.cs

示例14: QueryManager

 public QueryManager(Project project, TreeView tree, WorkItemStore itemStore)
 {
     ItemStore = itemStore;
     this.project = project;
     Tree = tree;
     project.QueryHierarchy.Refresh();
     BuildQueryHierarchy(project.QueryHierarchy);
 }
开发者ID:nkravch,项目名称:SALMA-2.0,代码行数:8,代码来源:QueryManager.cs

示例15: search

        public List<dynamic> search(DBModule.TypeOfDepth depth, String value,TreeView treeView1)
        {
            //IDataBase dataBase = new DataBase();
            ResultList = DataBase.ReceiveResults(depth, value);
            addDataToTree(treeView1, new List<dynamic>(), ResultList, depth, value, 0);

            return ResultList;
        }
开发者ID:bryk,项目名称:csharp-classdiagram-generator,代码行数:8,代码来源:Searcher.cs


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