本文整理汇总了C#中System.Windows.Controls.ItemCollection.Cast方法的典型用法代码示例。如果您正苦于以下问题:C# ItemCollection.Cast方法的具体用法?C# ItemCollection.Cast怎么用?C# ItemCollection.Cast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.ItemCollection
的用法示例。
在下文中一共展示了ItemCollection.Cast方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetContainerForItem
/// <summary>
/// Creates or identifies the element that is used to display the given item.
/// </summary>
/// <param name="item">The item to get the container for.</param>
/// <param name="itemCollection">The parent's <see cref="ItemCollection"/>.</param>
/// <returns>The element that is used to display the given item.</returns>
protected virtual RadTabItem GetContainerForItem( object item, ItemCollection itemCollection )
{
if ( itemCollection == null )
{
throw new ArgumentNullException ( "itemCollection" );
}
var container = item as RadTabItem;
if ( container != null && ( ( bool )container.GetValue ( IsGeneratedProperty ) ) == false )
{
return container;
}
return itemCollection.Cast<RadTabItem> ()
.Where ( tabItem => ( bool )tabItem.GetValue ( IsGeneratedProperty ) )
.FirstOrDefault ( tabItem => tabItem.Content == item );
}
示例2: UpdateMenu
private void UpdateMenu(ItemCollection globalItems, ItemCollection selfItems, IList<MenuItem> addedItems)
{
if (globalItems == null)
return;
if (selfItems == null)
return;
foreach (MenuItem self in selfItems)
{
var results = globalItems.Cast<MenuItem>().Where<MenuItem>(item => item.HasHeader && self.HasHeader && (self.Header == item.Header));
int count = results.Count<MenuItem>();
if (count == 0)
{
globalItems.Add(self);
AddSelfCommand2List(addedItems, self);
}
else if (count > 1)
throw new MenuItemConflictException("Menu item: " + self.Header);
else
{
MenuItem item = results.First<MenuItem>();
if (self.HasItems)
{
if (self.HasItems)
UpdateMenu(item.Items, self.Items, addedItems);
else if (!item.HasItems)
{
foreach (MenuItem sub in self.Items)
{
item.Items.Add(sub);
if (sub.Command != null)
addedItems.Add(sub);
}
}
}
}
}
}
示例3: GetSummary
protected internal override string GetSummary(ItemCollection items)
{
var mp = this._meta.PropertyMeta.ManagedProperty;
var sum = items.Cast<object>().Sum(item =>
{
var e = item as Entity;
var value = e.GetProperty(mp);
return Convert.ToDouble(value);
});
return sum.ToString();
}
示例4: Find
MenuItem Find(ItemCollection items, string header)
{
return items.Cast<MenuItem>()
.FirstOrDefault(i => i.Header.ToString() == header);
}