本文整理汇总了C#中System.Windows.Controls.ItemCollection.OfType方法的典型用法代码示例。如果您正苦于以下问题:C# ItemCollection.OfType方法的具体用法?C# ItemCollection.OfType怎么用?C# ItemCollection.OfType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.ItemCollection
的用法示例。
在下文中一共展示了ItemCollection.OfType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SearchForMenuItemRecursively
/// <summary>
/// Searches for given menu item.
/// First it tries to find it among first layer items (e.g. File, Edit, etc.)
/// If it doesn't find given menuitem, it tries to search one layer deeper.
/// </summary>
/// <param name="menuItems">Menu items among which we will search for needed item.</param>
/// <param name="searchItem">Menu item, that we want to find.</param>
/// <returns>Returns parent item for searched item.</returns>
private MenuItem SearchForMenuItemRecursively(ItemCollection menuItems, Control searchItem)
{
var collectionOfItems = menuItems.OfType<Control>();
foreach (var item in collectionOfItems)
{
if (item == searchItem)
return item.Parent as MenuItem;
}
var collectionOfMenuItems = menuItems.OfType<MenuItem>();
foreach (var item in collectionOfMenuItems)
{
return SearchForMenuItemRecursively(item.Items, searchItem);
}
return null;
}
示例2: ToTabsList
private List<TabItem> ToTabsList(ItemCollection tabs)
{
List<TabItem> TabsStart = tabs.OfType<TabItem>().ToList<TabItem>();
TabsStart.RemoveAt(TabsStart.Count - 1);
return TabsStart;
}