本文整理汇总了C#中System.Windows.Controls.ItemsControl.StoreItemValue方法的典型用法代码示例。如果您正苦于以下问题:C# ItemsControl.StoreItemValue方法的具体用法?C# ItemsControl.StoreItemValue怎么用?C# ItemsControl.StoreItemValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.ItemsControl
的用法示例。
在下文中一共展示了ItemsControl.StoreItemValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CleanupContainers
//.........这里部分代码省略.........
if (IsKeyboardFocusWithin && !IsPixelBased)
{
// If we're not in a hieararchy we can find the focus trail locally; for hierarchies it has already been
// precalculated.
FindFocusedChild(out focusedChild, out previousFocusable, out nextFocusable);
}
//
// Iterate over all realized children and recycle the ones that are eligible. Items NOT eligible for recycling
// have one or more of the following properties
//
// - inside the cache window
// - the item is its own container
// - has keyboard focus
// - is the first focusable item before or after the focused item
// - the CleanupVirtualizedItem event was canceled
//
for (int childIndex = 0; childIndex < children.Count; childIndex++)
{
child = (UIElement)children[childIndex];
lastItemIndex = itemIndex;
itemIndex = GetGeneratedIndex(childIndex);
// itemsControl.Items can change without notifying VirtualizingStackPanel (when ItemsSource is not an ObservableCollection or does not implement INotifyCollectionChanged).
// Fetch the item from the container instead of referencing from the Items collection.
item = itemsControl.ItemContainerGenerator.ItemFromContainer(child);
if (itemIndex - lastItemIndex != 1)
{
// There's a generated gap between the current item and the last. Clean up the last range of items.
performCleanup = true;
}
if (performCleanup)
{
if (cleanupRangeStart >= 0 && cleanupCount > 0)
{
//
// We've hit a non-virtualizable container or a non-contiguous section.
//
CleanupRange(children, Generator, cleanupRangeStart, cleanupCount);
// CleanupRange just modified the _realizedChildren list. Adjust the childIndex.
childIndex -= cleanupCount;
focusedChild -= cleanupCount;
previousFocusable -= cleanupCount;
nextFocusable -= cleanupCount;
cleanupCount = 0;
cleanupRangeStart = -1;
}
performCleanup = false;
}
if (IsOutsideCacheWindow(itemIndex) &&
!((IGeneratorHost)itemsControl).IsItemItsOwnContainer(item) &&
childIndex != focusedChild &&
childIndex != previousFocusable &&
childIndex != nextFocusable &&
!IsInFocusTrail(child) && // logically the same computation as the three above; used when in a treeview.
child != _bringIntoViewContainer && // the container we're going to bring into view must not be recycled
NotifyCleanupItem(child, itemsControl))
{
//
// The container is eligible to be virtualized
//
if (cleanupRangeStart == -1)
{
cleanupRangeStart = childIndex;
}
cleanupCount++;
//
// Save off the child's desired size if we're doing pixel-based virtualization.
// We need to save off the size when doing hierarchical (i.e. TreeView) virtualization, since containers will vary
// greatly in size. This is required both to compute the index of the first visible item in the viewport and to Arrange
// children in their proper locations.
//
if (IsPixelBased)
{
itemsControl.StoreItemValue(item, child.DesiredSize, _desiredSizeStorageIndex);
}
}
else
{
// Non-recyclable container;
performCleanup = true;
}
}
if (cleanupRangeStart >= 0 && cleanupCount > 0)
{
CleanupRange(children, Generator, cleanupRangeStart, cleanupCount);
}
}
示例2: ClearAllContainers
// Tells the Generator to clear out all containers for this ItemsControl. This is called by the ItemValueStorage
// service when the ItemsControl this panel is a host for is about to be thrown away. This allows the VSP to save
// off any properties it is interested in and results in a call to ClearContainerForItem on the ItemsControl, allowing
// the Item Container Storage to do so as well.
// Note: A possible perf improvement may be to make 'fast' RemoveAll on the Generator that simply calls ClearContainerForItem
// for us without walking through its data structures to actually clean out items.
internal void ClearAllContainers(ItemsControl itemsControl)
{
Debug.Assert(itemsControl == ItemsControl.GetItemsOwner(this),
"We can only clear containers that this panel is a host for");
IItemContainerGenerator generator = Generator;
if (IsPixelBased)
{
IList children = RealizedChildren;
UIElement child;
for (int i = 0; i < children.Count; i++)
{
child = (UIElement)children[i];
itemsControl.StoreItemValue(((ItemContainerGenerator)generator).ItemFromContainer(child), child.DesiredSize, _desiredSizeStorageIndex);
}
}
if (generator != null)
{
generator.RemoveAll();
}
}