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


C# ItemCollection.Add方法代码示例

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


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

示例1: AddMenuItem

        MenuItem AddMenuItem(ItemCollection items, string header, MyMenuInfo menuInfo)
        {
            var menuItem = menuInfo.CreateMenuItem(header);
            items.Add(menuItem);

            return menuItem;
        }
开发者ID:RookieOne,项目名称:JBsWpfExamples,代码行数:7,代码来源:WpfMenu.cs

示例2: UpdateView

 private void UpdateView(ItemCollection itemCollection, IEnumerable<String> items)
 {
     itemCollection.Clear();
     foreach (var item in items)
     {
         var description = String.IsNullOrEmpty(item) ? "Unknown" : item;
         itemCollection.Add(description);
     }
 }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:9,代码来源:UndoHistoryVisualiserWindow.xaml.cs

示例3: AddMenuItem

        MenuItem AddMenuItem(ItemCollection items, string header, ICommand command)
        {
            var menuItem = new MenuItem();
            menuItem.Header = header;
            menuItem.Command = command;

            items.Add(menuItem);

            return menuItem;
        }
开发者ID:RookieOne,项目名称:Chimera,代码行数:10,代码来源:WpfMenu.cs

示例4: FillProject

        void FillProject(ItemCollection pitem, string path)
        {
            var dirs = System.IO.Directory.GetDirectories(path);
            foreach (var d in dirs)
            {
                TreeViewItem i = new TreeViewItem();
                StackPanel panel = new StackPanel();
                panel.Orientation = Orientation.Horizontal;
                Image pic = new Image();
                pic.Source = new BitmapImage(new Uri("1.jpg", UriKind.Relative));
                pic.Width = 18;
                pic.Height = 18;
                panel.Children.Add(pic);
                TextBlock tb = new TextBlock();
                tb.Text = System.IO.Path.GetFileName(d);
                panel.Children.Add(tb);
                i.Header = panel;// "<Path>" + System.IO.Path.GetFileName(d);

                FillProject(i.Items, d);
                if (i.Items.Count > 0)
                    pitem.Add(i);

            }
            var files = System.IO.Directory.GetFiles(path, "*.cs");
            foreach (var f in files)
            {
                TreeViewItem i = new TreeViewItem();
                StackPanel panel = new StackPanel();
                panel.Orientation = Orientation.Horizontal;
                Image pic = new Image();
                pic.Source = new BitmapImage(new Uri("2.jpg", UriKind.Relative));
                pic.Width = 18;
                pic.Height = 18;
                panel.Children.Add(pic);
                TextBlock tb = new TextBlock();
                tb.Text = System.IO.Path.GetFileName(f);
                panel.Children.Add(tb);
                i.Header = panel;
                i.Tag = f;
                pitem.Add(i);

            }
        }
开发者ID:GraphicGame,项目名称:CSLightStudio,代码行数:43,代码来源:MainWindow.xaml.cs

示例5: AddTreeViewItem

        private void AddTreeViewItem(ItemCollection items, WorkItem workItem)
        {
            bool firstChild = (items.Count == 0);
            WorkItemTreeViewItem item = new WorkItemTreeViewItem(workItem);
            items.Add(item);

            if (firstChild && (item.Parent is WorkItemTreeViewItem))
            {
                (item.Parent as WorkItemTreeViewItem).IsExpanded = true;
            }
        }
开发者ID:BackupTheBerlios,项目名称:sofia-svn,代码行数:11,代码来源:WorkItemVisualizer.xaml.cs

示例6: ItemCollectionDefaultViewTest

        public void ItemCollectionDefaultViewTest()
        {
            ItemCollection itemCollection = new ItemCollection();

            NotifyCollectionChangedEventArgs lastChangeArgs = null;
            itemCollection.CollectionChanged += (sender, e) => lastChangeArgs = e;

            itemCollection.Add("default1");

            Assert.AreEqual(NotifyCollectionChangedAction.Add, lastChangeArgs.Action);
            CollectionAssert.AreEqual(new[] { "default1" }, lastChangeArgs.NewItems.Cast<string>().ToArray());
        }
开发者ID:highzion,项目名称:Granular,代码行数:12,代码来源:ItemCollectionTest.cs

示例7: add_children

 private void add_children(ItemCollection group, int? id)
 {
     foreach (KeyValuePair<int,MarketGroup> mg in market_groups) {
         if (mg.Value.parent_id == id) {
             TreeViewItem item = new TreeViewItem();
             item.Header = mg.Value.name;
             item.Tag = mg.Key;
             if (!mg.Value.has_types)
                 add_children(item.Items, mg.Key);
             group.Add(item);
         }
     }
 }
开发者ID:raylu,项目名称:emb,代码行数:13,代码来源:MainWindow.xaml.cs

示例8: FillTree

        private void FillTree(ItemCollection itemColl, RepositoryUnit dataNode)
        {
            TreeViewItem tvi = new TreeViewItem();
            tvi.IsExpanded = true;
            
            itemColl.Add(tvi);
            //If its a potential draggable object we put his item id into it
            if (dataNode.IsLeaf)
                tvi.Name = dataNode.ItemId;

            tvi.Header = dataNode.Name;
            
            foreach (RepositoryUnit childDataNode in dataNode.Children)
            {
                FillTree(tvi.Items, childDataNode); 
            }
        }  // end method
开发者ID:SamuelToh,项目名称:Masters_Degree_Major_Project,代码行数:17,代码来源:PatternRepository.xaml.cs

示例9: appendToTreeView

 private void appendToTreeView(ItemCollection itemCollection, String[] path, KeyValuePair<String[], ISettingGroup> kvSettingGroup)
 {
     TreeViewItem tvItem = this.getTreeViewItem(itemCollection, path[0]);
     if (tvItem == null) {
         tvItem = new TreeViewItem();
         tvItem.Header = path[0];
         tvItem.DataContext = kvSettingGroup;
         tvItem.IsExpanded = true;
         itemCollection.Add(tvItem);
     }
     //
     if (path.Length > 1) {
         String[] newPath = new String[path.Length - 1];
         for (int i = 1; i < path.Length; i++) {
             newPath[i - 1] = path[i];
         }
         this.appendToTreeView(tvItem.Items, newPath, kvSettingGroup);
     }
 }
开发者ID:RBernhardt,项目名称:unisono,代码行数:19,代码来源:UISettings.xaml.cs

示例10: ProcessElement

        private void ProcessElement(IHTMLElement parentElement,
          ItemCollection nodes)
        {
            // Scan through the collection of elements.
            foreach (IHTMLElement element in parentElement.children)
            {
                // Create a new node that shows the tag name.
                TreeViewItem node = new TreeViewItem();
                node.Header = "<" + element.tagName + ">";
                nodes.Add(node);

                if ((element.children.length == 0) && (element.innerText != null))
                {
                    // If this element doesn't contain any other elements, add
                    // any leftover text content as a new node.
                    node.Items.Add(element.innerText);
                }
                else
                {
                    // If this element contains other elements, process them recursively.
                    ProcessElement(element, node.Items);
                }
            }
        }
开发者ID:ittray,项目名称:LocalDemo,代码行数:24,代码来源:BrowseDOM.xaml.cs

示例11: Fill

        void Fill(ItemCollection treeNodes, ReadOnlyCollection<ReflectionStruct> nodes)
        {
            foreach (var node in nodes)
              {
            var treeNode = new TreeViewItem();
            treeNode.Header = node.Description;
            treeNode.Tag = node;
            treeNode.Expanded += node_Expanded;
            if (node.Location.Length == 0)
              treeNode.Background = new SolidColorBrush(Color.FromRgb(200, 255, 200));

            treeNodes.Add(treeNode);

            if (node.Children.Count != 0)
              treeNode.Items.Add(new TreeViewItem());
              }
        }
开发者ID:hwwang,项目名称:Nitra,代码行数:17,代码来源:MainWindow.xaml.cs

示例12: PopulateFileSystemTree

    private async Task<bool> PopulateFileSystemTree(ItemCollection items, string path)
    {
      items.Clear();
      MpdDirectoryListing list = null;
      try{
        list = await Task.Factory.StartNew(() => m_Mpc.LsInfo(path));
      }catch (Exception ex){
        ShowException(ex);
        return false;
      }

      foreach (string dir in list.DirectoryList) {
        TreeViewItem item = new TreeViewItem();
        item.Header = path != null ? dir.Remove(0, path.Length + 1) : dir;
        item.Tag = dir;
        if (await HasSubdirectories(item.Tag.ToString())) {
          item.Items.Add(null);
          item.Expanded += TreeItemExpanded;
        }
        items.Add(item);
      }
      return true;
    }
开发者ID:sakya,项目名称:wpfmpdclient,代码行数:23,代码来源:MainWindow.xaml.cs

示例13: Analyze

        private void Analyze(Type type, MethodInfo method, ItemCollection collection, TestFixtureView fixture)
        {
            if (method.GetCustomAttributes(typeof(TestAttribute), false).Count() > 0)
            {

                var testcase = new TestcaseView(type, method);
                collection.Add(CreateItem(testcase));
                fixture.AddTest(testcase);
            }
            else if (method.GetCustomAttributes(typeof(SetUpAttribute), false).Count() > 0)
            {
                fixture.SetupMethod = method;
            }
            else if (method.GetCustomAttributes(typeof(TearDownAttribute), false).Count() > 0)
            {
                fixture.TeardownMethod = method;
            }
        }
开发者ID:ArildF,项目名称:GitSharp,代码行数:18,代码来源:TestRunner.xaml.cs

示例14: AddPersonToTree

        void AddPersonToTree(Person p, ItemCollection items)
        {
            // create an item for this person
            var item = new TreeViewItem();
            item.Tag = p;
            item.Header = p.Name;

            // add this person to the tree
            items.Add(item);

            // and add any children
            foreach (var child in p.Children)
            {
                AddPersonToTree(child, item.Items);
            }
        }
开发者ID:mdjabirov,项目名称:C1Decompiled,代码行数:16,代码来源:MainWindow.xaml.cs

示例15: PopulateEntries

 /// <summary>
 /// Add nodes to a tree view item collection.
 /// </summary>
 /// <param name="parentCollection"></param>
 /// <param name="entries"></param>
 private void PopulateEntries( ItemCollection parentCollection, IEnumerable<IEntry> entries )
 {
     foreach( IEntry entry in entries )
     {
         ExtendedTreeViewItem item = this.CreateTreeViewItem( entry, parentCollection );
         parentCollection.Add( item );
         if( entry.Children.Count > 0 )
             this.PopulateEntries( item.Items, entry.Children );
     }
 }
开发者ID:tkrehbiel,项目名称:Tewpf,代码行数:15,代码来源:Window1.xaml.cs


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