本文整理汇总了C#中System.Windows.Controls.ItemsControl.ReadItemValue方法的典型用法代码示例。如果您正苦于以下问题:C# ItemsControl.ReadItemValue方法的具体用法?C# ItemsControl.ReadItemValue怎么用?C# ItemsControl.ReadItemValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.ItemsControl
的用法示例。
在下文中一共展示了ItemsControl.ReadItemValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ContainerSizeForItem
/// <summary>
/// Returns the size of the container for a given item. The size can come from the container, a lookup, or a guess depending
/// on the virtualization state of the item.
/// </summary>
/// <param name="itemsControl"></param>
/// <param name="item"></param>
/// <param name="index"></param>
/// <param name="container">returns the container for the item; null if the container wasn't found</param>
/// <returns></returns>
private Size ContainerSizeForItem(ItemsControl itemsControl, object item, int index, out UIElement container)
{
Size containerSize;
container = index >= 0 ? ((ItemContainerGenerator)Generator).ContainerFromIndex(index) as UIElement : null;
if (container != null)
{
containerSize = container.DesiredSize;
}
else
{
// It's virtualized; grab the height off the item if available.
object value = itemsControl.ReadItemValue(item, _desiredSizeStorageIndex);
if (value != null)
{
containerSize = (Size)value;
}
else
{
//
// No stored container height; simply guess.
//
containerSize = new Size();
if (Orientation == Orientation.Horizontal)
{
containerSize.Width = ContainerStackingSizeEstimate(itemsControl, /*isHorizontal = */ true);
containerSize.Height = DesiredSize.Height;
}
else
{
containerSize.Height = ContainerStackingSizeEstimate(itemsControl, /*isHorizontal = */ false);
containerSize.Width = DesiredSize.Width;
}
}
}
Debug.Assert(!containerSize.IsEmpty, "We can't estimate an empty size");
return containerSize;
}