本文整理匯總了C#中System.Windows.Controls.Menu.AddMenuItems方法的典型用法代碼示例。如果您正苦於以下問題:C# Menu.AddMenuItems方法的具體用法?C# Menu.AddMenuItems怎麽用?C# Menu.AddMenuItems使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Windows.Controls.Menu
的用法示例。
在下文中一共展示了Menu.AddMenuItems方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: When_adding_menu_item_should_be_able_to_add_to_root_menu
public void When_adding_menu_item_should_be_able_to_add_to_root_menu()
{
Menu menu = new Menu { Name = "MainMenu" };
menu.AddMenuItems(new MenuItemData { Parent = "MainMenu" });
Assert.AreEqual(1, menu.Items.Count);
}
示例2: When_adding_menu_items_should_be_able_to_add_to_child_menu_item
public void When_adding_menu_items_should_be_able_to_add_to_child_menu_item()
{
Menu menu = new Menu { Name = "MainMenu" };
MenuItem child = new MenuItem { Name = "Child" };
menu.Items.Add(child);
menu.AddMenuItems(new MenuItemData { Parent = "Child" });
Assert.AreEqual(1, child.Items.Count);
}
示例3: When_adding_menu_item_and_the_parent_does_not_exist_should_ignore_addition
public void When_adding_menu_item_and_the_parent_does_not_exist_should_ignore_addition()
{
Menu menu = new Menu { Name = "MainMenu" };
MenuItem child = new MenuItem { Name = "Child" };
menu.Items.Add(child);
menu.AddMenuItems(new MenuItemData { Parent = "Grandchild" });
Assert.AreEqual(1, menu.Items.Count);
Assert.AreEqual(0, child.Items.Count);
}