本文整理汇总了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;
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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;
}
}
示例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());
}
示例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);
}
}
}
示例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
示例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);
}
}
示例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);
}
}
}
示例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());
}
}
示例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;
}
示例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;
}
}
示例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);
}
}
示例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 );
}
}