BinaryVirtualizingWrapPanel
A class that behaves like a WrapPanel control, with additional ability out-of-the-box scrolling and being able to automatically virtualize/realize the content.
public partial class BinaryVirtualizingWrapPanel : VirtualizingPanel, IScrollInfo, ISupportTransactionalUpdates
Inherits from / implements: VirtualizingPanel, IScrollInfo, ISupportTransactionalUpdates
Remarks
How this control works. The panel is its own scroll owner: it implements IScrollInfo, so the ScrollViewer around its items control asks it for the extent and the offsets instead of measuring everything. In MeasureOverride it works out, from the offset and the viewport, which items can be seen (plus a margin of ReRenderVisibilityRangeMaxCount either side), asks the items control's generator for containers for those only, and removes the containers that have gone out of range. Everything else exists only as data. Two layouts. With every item the size of ItemDimension (the default), a line holds a fixed number of cells and an item's position is arithmetic on its index - which is what makes scrolling straight to any index cheap (DesiredChildIndexToScrollTo). ItemPositioningMode decides how many cells a line takes. With IsVariableItemSizeEnabled or IsDataSourceGrouped, the flow layout takes over: items wrap at their own measured size, and a size not yet measured is estimated as ItemDimension. Grouping. The panel does not see WPF's group items. Bind the items control to a VirtualizingCollectionView , which presents each group's header as a row of the flat list, and set IsDataSourceGrouped; the panel then starts a new line for each header and virtualises the headers with the items. Margins. The panel sets its own Margin from RendertimeMargin (and IsExtraMarginAtStartupRequired) when it joins the visual tree; set those rather than Margin . It needs a bounded viewport. Virtualisation is only possible when the items control is given a finite size along the scrolling direction. Inside a StackPanel (or any parent that measures its children with unlimited space that way), there is no viewport to fill; give the items control a height or width, or put it in a Grid or DockPanel. Virtualisation applies to items that come from data binding.
Members at a glance
BinaryVirtualizingWrapPanel | Initializes a new instance of the BinaryVirtualizingWrapPanel class. |
AutoUpdateViewportOnDetectingTransactionalUpdatesToDataSource | Gets or sets a value indicating whether [automatic update viewport on detecting transactional updates to data source]. |
CanHorizontallyScroll | Gets or sets a value that indicates whether scrolling on the horizontal axis is possible. |
CanVerticallyScroll | Gets or sets a value that indicates whether scrolling on the vertical axis is possible. |
CustomExtraSpacingBetweenGroupHeaderRowAndDataItemRow | Gets or sets a custom extra spacing to render between the group header row and the data item row. |
CustomExtraSpacingBetweenGroupRenderingCompletionAndGroupHeaderRowRenderingBegins | Gets or sets the custom extra spacing to render between where a group rendering completes and the next group header row rendering begins. |
DesiredChildIndexScrollingIsDataContextSynchronized | Gets or sets whether the control's DesiredChildIndexToScrollTo is set to be synchronized with the current item in the data context. |
DesiredChildIndexToScrollTo | Gets or sets the desired child index to scroll to. |
ExtentHeight | Gets the vertical size of the extent. |
ExtentWidth | Gets the horizontal size of the extent. |
GroupHeaderItemCustomHeight | Gets or sets a custom height when rendering the group header using a custom Datatemplate. |
GroupVirtualizationMode | Gets or sets the virtualization mode when grouping is enabled on the data source. |
HorizontalOffset | Gets the horizontal offset of the scrolled content. |
IsAnimationEnabled | Gets or sets a value indicating whether this instance is animation enabled. |
IsAnimationEnabledWhenScrollToASpecificChildIndex | Gets or sets a value indicating whether this instance is animation enabled for deterministically scrolling to a specific child index. |
IsDataSourceGrouped | Gets or sets whether the data source of the items control is set up with grouping information. |
IsDynamicConstructionCapabilityEnabled | Gets or sets a value indicating whether this instance is dynamic construction capability enabled. |
IsExtraMarginAtStartupRequired | Gets or sets a value indicating whether this instance is extra margin at startup required. |
IsRenderItemDimensionHeightSpacingBetweenGroupHeaderAndDataItemRowEnabled | Gets or sets whether to render spacing between the group header and data item row. |
IsTrimExtraLinkbreakForLeadingRowWithOneChildEnabled | Gets or sets whether to automatically trim the extra leading space between header and row data if there is only one child per row that is being rendered. |
IsVariableItemSizeEnabled | Gets or sets a value indicating whether items may each be a different size. |
ItemDimension | Gets or sets the size of the content items. |
ItemPositioningMode | Gets or sets the item positioning mode. |
Orientation | Gets or sets the orientation for laying-out the children items. |
PanelAnimationEffect | Gets or sets the panel animation effect. |
ReRenderVisibilityRangeMaxCount | Gets or sets the maximum number of items that the control has to prepare when about to re-render the viewport due to a trigger to the view invalidation. |
RendertimeMargin | Gets or sets the rendertime margin. |
ScrollOwner | Gets or sets a ScrollViewer element that controls scrolling behavior. |
ShouldAdjustRightHorizontalAlignmentSetupConsideringScrollInfo | Gets or sets a value indicating whether the control should adjust right horizontal alignment margin setup considering the host ItemsControl scrollbar visual. |
ShouldAutoAdjustParentItemsControlInternalPadding | Gets or sets whether the component should automatically adjust the internal padding setup in the Control styles of the owner ItemsControl. |
ShouldRecomputeViewportExtentSpacingUponAlignment | Gets or sets a value indicating whether the control should recompute the viewport vis-a-vis extent spacing upon alignment. |
ShouldRenderExtraLineBeforeHeader | Gets or sets a value indicating whether the control should render an extra line before header in standalone line rendering mode. |
ShouldRenderItemHeightSpacingAfterAGroupHasBeenRendered | Gets or sets a value indicating whether the control should render an item height worth of spacing after a group has been rendered. |
ShouldShareUnusedSpaceEquallyOnHorizontalAlignment | Gets or sets a value indicating whether the control should share unused space equally on horizontal alignment. |
ShouldUseRenderTimeMarginValuesWhenRecomputingViewPortExtentSpacingAdjustment | Gets or sets a value indicating whether the control should use the value set for RendertimeMargin relevant values when recomputing view port extent spacing adjustment for the property ShouldRecomputeViewportExtentSpacingUponAlignment. |
VerticalOffset | Gets the vertical offset of the scrolled content. |
ViewportHeight | Gets the vertical size of the viewport for this content. |
ViewportWidth | Gets the horizontal size of the viewport for this content. |
VirtualizationSchemeOption | Gets or sets the virtualization scheme. |
VirtualizationSchemeWhenScrollingToASpecificChildIndex | Gets or sets the VirtualizationScheme to use, when scrolling to a specific child. |
ArrangeOverride | When overridden in a derived class, positions child elements and determines a size for a FrameworkElement derived class. |
LineDown | Scrolls down within content by one logical unit. |
LineLeft | Scrolls left within content by one logical unit. |
LineRight | Scrolls right within content by one logical unit. |
LineUp | Scrolls up within content by one logical unit. |
MakeVisible | This method is not available in the Virtualization scenario. |
MeasureOverride | When overridden in a derived class, measures the size in layout required for child elements and determines a size for the FrameworkElement-derived class. |
MouseWheelDown | Scrolls down within content after a user clicks the wheel button on a mouse. |
MouseWheelLeft | Scrolls left within content after a user clicks the wheel button on a mouse. |
MouseWheelRight | Scrolls right within content after a user clicks the wheel button on a mouse. |
MouseWheelUp | Scrolls up within content after a user clicks the wheel button on a mouse. |
OnIsItemsHostChanged | Measures again when the panel becomes an items host, which on a page's first show happens after the panel's first measure pass. |
OnItemsChanged | Called when the Items collection that is associated with the ItemsControl for this Panel changes. |
OnKeyDown | Invoked when an unhandled KeyDown attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event. |
OnRenderSizeChanged | Raises the SizeChanged event, using the specified information as part of the eventual event data. |
PageDown | Scrolls down within content by one page. |
PageLeft | Scrolls left within content by one page. |
PageRight | Scrolls right within content by one page. |
PageUp | Scrolls up within content by one page. |
Refresh | Performs deterministic update of the virtualized viewport data. An implementation for Refresh. |
ScrollToTheDesiredChild | Scrolls to the desired child. |
SetHorizontalOffset | Sets the amount of horizontal offset. |
SetVerticalOffset | Sets the amount of vertical offset. |
AboutToRenderChildItems | Raised when the control is about to render / display the items in the viewport. |
CustomExtraSpacingBetweenGroupHeaderRowAndDataItemRowProperty | The custom extra spacing between group header row and data item row property |
CustomExtraSpacingBetweenGroupRenderingCompletionAndGroupHeaderRowRenderingBeginsProperty | The custom extra spacing between group rendering completion and group header row rendering begins property |
DesiredChildIndexScrollingIsDataContextSynchronizedProperty | The desired child index scrolling is data context synchronized property |
DesiredChildIndexToScrollToProperty | DesiredChildIndexToScrollToProperty property. |
GroupHeaderItemCustomHeightProperty | The group header item custom height property |
GroupVirtualizationModeProperty | Gets or sets the virtualization mode when grouping is enabled on the data source. |
IsAnimationEnabledProperty | IsAnimationEnabledProperty property. |
IsAnimationEnabledWhenScrollToASpecificChildIndexProperty | IsAnimationEnabledForDeterministicScrollToASpecificChildIndexProperty property. |
IsDataSourceGroupedProperty | Gets or sets whether the data source of the items control is set up with grouping information. |
IsDynamicConstructionCapabilityEnabledProperty | The is dynamic construction capability enabled property |
IsExtraMarginAtStartupRequiredProperty | The is extra margin at startup required property |
IsRenderItemDimensionHeightSpacingBetweenGroupHeaderAndDataItemRowEnabledProperty | The is render item dimension height spacing between group header and data item row enabled property |
IsTrimExtraLinkbreakForFirstRowEnabledProperty | The is trim extra linkbreak for first row enabled property |
IsVariableItemSizeEnabledProperty | Identifies the IsVariableItemSizeEnabled dependency property. |
ItemDimensionProperty | ItemDimensionProperty property. |
ItemPositioningModeProperty | The item positioning mode property |
OrientationProperty | OrientationProperty property. |
PanelAnimationEffectProperty | PanelAnimationEffectProperty property. |
ReRenderVisibilityRangeMaxCountProperty | The re render visibility range maximum count property |
RendertimeMarginProperty | The rendertime margin property |
ShouldAutoAdjustParentItemsControlInternalPaddingProperty | Identifies the ShouldAutoAdjustParentItemsControlInternalPadding dependency property. |
ShouldRenderExtraLineBeforeHeaderProperty | Gets or sets a value indicating whether the control should render an extra line before header in standalone line rendering mode. |
ShouldRenderItemHeightSpacingAfterAGroupHasBeenRenderedProperty | The should render item height spacing after a group has been rendered property |
VirtualizationSchemeOptionProperty | VirtualizationSchemeOptionProperty property. |
VirtualizationSchemeWhenScrollingToASpecificChildIndexProperty | VirtualizationSchemeWhenScrollingToASpecificChildIndexProperty property. |
Constructors
BinaryVirtualizingWrapPanel
Initializes a new instance of the BinaryVirtualizingWrapPanel class.
Properties
AutoUpdateViewportOnDetectingTransactionalUpdatesToDataSource
Gets or sets a value indicating whether [automatic update viewport on detecting transactional updates to data source].
Value. true if [automatic update viewport on detecting transactional updates to data source]; otherwise, false .
CanHorizontallyScroll
Gets or sets a value that indicates whether scrolling on the horizontal axis is possible.
Value. true if this instance can horizontally scroll; otherwise, false .
CanVerticallyScroll
Gets or sets a value that indicates whether scrolling on the vertical axis is possible.
Value. true if this instance can vertically scroll; otherwise, false .
CanHorizontallyScroll.CustomExtraSpacingBetweenGroupHeaderRowAndDataItemRow
Gets or sets a custom extra spacing to render between the group header row and the data item row.
Value. The custom extra spacing between group header row and data item row.
IsRenderItemDimensionHeightSpacingBetweenGroupHeaderAndDataItemRowEnabled to false, then this automatic spacing will not be rendered. In that case, the control renders this property's spacing between the group header row and the data item row instead - 8 units by default.
CustomExtraSpacingBetweenGroupRenderingCompletionAndGroupHeaderRowRenderingBegins
Gets or sets the custom extra spacing to render between where a group rendering completes and the next group header row rendering begins.
Value. The custom extra spacing between group rendering completion and group header row rendering begins.
ShouldRenderItemHeightSpacingAfterAGroupHasBeenRendered is set to false. By default the value of this property is set to 48.0.
Note that the maximum value this property can be set to is 80% of the
ItemDimension's Height value.DesiredChildIndexScrollingIsDataContextSynchronized
Gets or sets whether the control's DesiredChildIndexToScrollTo is set to be synchronized with the current item in the data context.
Value. true if [desired child index scrolling is data context synchronized]; otherwise, false .
DesiredChildIndexToScrollTo
Gets or sets the desired child index to scroll to.
Value. The desired child index to scroll to.
ExtentHeight
Gets the vertical size of the extent.
Value. The height of the extent.
ExtentWidth
Gets the horizontal size of the extent.
Value. The width of the extent.
GroupHeaderItemCustomHeight
Gets or sets a custom height when rendering the group header using a custom Datatemplate.
Value. The height of the group header item custom.
GroupVirtualizationMode
Gets or sets the virtualization mode when grouping is enabled on the data source.
Value. The group virtualization mode.
HorizontalOffset
Gets the horizontal offset of the scrolled content.
Value. The horizontal offset.
IsAnimationEnabled
Gets or sets a value indicating whether this instance is animation enabled.
Value. true if this instance is animation enabled; otherwise, false .
IsAnimationEnabledWhenScrollToASpecificChildIndex
Gets or sets a value indicating whether this instance is animation enabled for deterministically scrolling to a specific child index.
Value. true if this instance is animation enabled when scroll to a specific child index; otherwise, false .
IsDataSourceGrouped
Gets or sets whether the data source of the items control is set up with grouping information.
Value. true if this instance is data source grouped; otherwise, false .
IsDynamicConstructionCapabilityEnabled
Gets or sets a value indicating whether this instance is dynamic construction capability enabled.
Value. true if this instance is dynamic construction capability enabled; otherwise, false .
IsExtraMarginAtStartupRequired
Gets or sets a value indicating whether this instance is extra margin at startup required.
Value. true if for this instance, the extra margin at startup is required; otherwise, false .
RendertimeMargin when the panel sets its margin: when it joins the visual tree, and at once if it already has.IsRenderItemDimensionHeightSpacingBetweenGroupHeaderAndDataItemRowEnabled
Gets or sets whether to render spacing between the group header and data item row.
Value. true if this instance is render item dimension height spacing between group header and data item row enabled; otherwise, false .
ItemDimension property.IsTrimExtraLinkbreakForLeadingRowWithOneChildEnabled
Gets or sets whether to automatically trim the extra leading space between header and row data if there is only one child per row that is being rendered.
Value. true if this instance is trim extra linkbreak for leading row with one child enabled; otherwise, false .
IsVariableItemSizeEnabled
Gets or sets a value indicating whether items may each be a different size.
Value. false , the default, to lay every item out in a cell of ItemDimension; true to give each item the size it asks for.
Vertical) and wrap when the line is full; a line is as tall as its tallest item. An item is measured when it first comes into view, and its size is remembered; until then ItemDimension is used as its estimate, so set it to a typical item size. Grouping works with variable sizes too.ItemDimension
Gets or sets the size of the content items.
Value. The size of the item.
ItemPositioningMode
Gets or sets the item positioning mode.
Value. The item positioning mode. The default is Safe.
Safe holds whole items only: what is left over at the end of the line stays empty, and every item the user can see is complete.
Greedy takes one more item when the space left at the end of the line is at least 85 per cent of an item, so a line that would otherwise waste most of an item's width uses it. The last item on such a line is clipped, by at most fifteen per cent of its own width.
With a grouped source, Safe also keeps one item's width (or height) of each line for the group's own furniture; Greedy does not.
Orientation
Gets or sets the orientation for laying-out the children items.
Value. The orientation.
PanelAnimationEffect
Gets or sets the panel animation effect.
Value. The AnimationEffect.
ReRenderVisibilityRangeMaxCount
Gets or sets the maximum number of items that the control has to prepare when about to re-render the viewport due to a trigger to the view invalidation.
Value. The re render visibility range maximum count.
RendertimeMargin
Gets or sets the rendertime margin.
Value. The rendertime margin.
ScrollOwner
Gets or sets a ScrollViewer element that controls scrolling behavior.
Value. The scroll owner.
ShouldAdjustRightHorizontalAlignmentSetupConsideringScrollInfo
Gets or sets a value indicating whether the control should adjust right horizontal alignment margin setup considering the host ItemsControl scrollbar visual.
Value. true if [should adjust right horizontal alignment setup considering scroll information]; otherwise, false .
ShouldAutoAdjustParentItemsControlInternalPadding
Gets or sets whether the component should automatically adjust the internal padding setup in the Control styles of the owner ItemsControl.
ShouldRecomputeViewportExtentSpacingUponAlignment
Gets or sets a value indicating whether the control should recompute the viewport vis-a-vis extent spacing upon alignment.
Value. true if [should recompute viewport extent spacing upon alignment]; otherwise, false .
ShouldRenderExtraLineBeforeHeader
Gets or sets a value indicating whether the control should render an extra line before header in standalone line rendering mode.
Value. true if [should render extra line before header]; otherwise, false .
ShouldRenderItemHeightSpacingAfterAGroupHasBeenRendered
Gets or sets a value indicating whether the control should render an item height worth of spacing after a group has been rendered.
Value. true if [should render item height spacing after a group has been rendered]; otherwise, false .
ItemDimension Height value worth of spacing between where a group's rendering completes and where the next header row begins. Left false - the default - that spacing comes from
CustomExtraSpacingBetweenGroupRenderingCompletionAndGroupHeaderRowRenderingBegins instead, which is 48.0 unless you set it.ShouldUseRenderTimeMarginValuesWhenRecomputingViewPortExtentSpacingAdjustment
Gets or sets a value indicating whether the control should use the value set for RendertimeMargin relevant values when recomputing view port extent spacing adjustment for the property ShouldRecomputeViewportExtentSpacingUponAlignment.
Value. true if [should use render time margin values when recomputing view port extent spacing adjustment]; otherwise, false .
VerticalOffset
Gets the vertical offset of the scrolled content.
Value. The vertical offset.
ViewportHeight
Gets the vertical size of the viewport for this content.
Value. The height of the viewport.
ViewportWidth
Gets the horizontal size of the viewport for this content.
Value. The width of the viewport.
VirtualizationSchemeOption
Gets or sets the virtualization scheme.
Value. The virtualization scheme.
IsDataSourceGrouped is set to true, the only VirtualizationScheme value you can use is VirtualizationScheme.LightWeightCache.VirtualizationSchemeWhenScrollingToASpecificChildIndex
Gets or sets the VirtualizationScheme to use, when scrolling to a specific child.
Value. The index of the virtualization scheme when scrolling to a specific child.
Methods
ArrangeOverride
When overridden in a derived class, positions child elements and determines a size for a FrameworkElement derived class.
- finalSize
- The final area within the parent that this element should use to arrange itself and its children.
Returns. The actual size used.
LineDown
Scrolls down within content by one logical unit.
LineLeft
Scrolls left within content by one logical unit.
LineRight
Scrolls right within content by one logical unit.
LineUp
Scrolls up within content by one logical unit.
MakeVisible
This method is not available in the Virtualization scenario.
- visual
- A
Visualthat becomes visible. - rectangle
- A bounding rectangle that identifies the coordinate space to make visible.
Returns. A Rect that is visible.
MeasureOverride
When overridden in a derived class, measures the size in layout required for child elements and determines a size for the FrameworkElement-derived class.
- availableSize
- The available size that this element can give to child elements. Infinity can be specified as a value to indicate that the element will size to whatever content is available.
Returns. The size that this element determines it needs during layout, based on its calculations of child element sizes.
MouseWheelDown
Scrolls down within content after a user clicks the wheel button on a mouse.
MouseWheelLeft
Scrolls left within content after a user clicks the wheel button on a mouse.
MouseWheelRight
Scrolls right within content after a user clicks the wheel button on a mouse.
MouseWheelUp
Scrolls up within content after a user clicks the wheel button on a mouse.
OnIsItemsHostChanged
Measures again when the panel becomes an items host, which on a page's first show happens after the panel's first measure pass.
- oldIsItemsHost
- The old value.
- newIsItemsHost
- The new value.
OnItemsChanged
Called when the Items collection that is associated with the ItemsControl for this Panel changes.
- sender
- The
Objectthat raised the event. - args
- Provides data for the
ItemsChangedevent.
OnKeyDown
Invoked when an unhandled KeyDown attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.
- e
- The
KeyEventArgsthat contains the event data.
OnRenderSizeChanged
Raises the SizeChanged event, using the specified information as part of the eventual event data.
- sizeInfo
- Details of the old and new size involved in the change.
PageDown
Scrolls down within content by one page.
PageLeft
Scrolls left within content by one page.
PageRight
Scrolls right within content by one page.
PageUp
Scrolls up within content by one page.
Refresh
Performs deterministic update of the virtualized viewport data. An implementation for Refresh.
ScrollToTheDesiredChild
Scrolls to the desired child.
- desiredChildIndexToScrollTo
- The desired child index to scroll to.
- performAnimation
- if set to true [perform animation].
- virtualizationScheme
- The desired
VirtualizationScheme.
SetHorizontalOffset
Sets the amount of horizontal offset.
- offset
- The degree to which content is horizontally offset from the containing viewport.
SetVerticalOffset
Sets the amount of vertical offset.
- offset
- The degree to which content is vertically offset from the containing viewport.
Events
AboutToRenderChildItems
Raised when the control is about to render / display the items in the viewport.
Fields
CustomExtraSpacingBetweenGroupHeaderRowAndDataItemRowProperty
The custom extra spacing between group header row and data item row property
CustomExtraSpacingBetweenGroupRenderingCompletionAndGroupHeaderRowRenderingBeginsProperty
The custom extra spacing between group rendering completion and group header row rendering begins property
DesiredChildIndexScrollingIsDataContextSynchronizedProperty
The desired child index scrolling is data context synchronized property
DesiredChildIndexToScrollToProperty
DesiredChildIndexToScrollToProperty property.
GroupHeaderItemCustomHeightProperty
The group header item custom height property
GroupVirtualizationModeProperty
Gets or sets the virtualization mode when grouping is enabled on the data source.
IsAnimationEnabledProperty
IsAnimationEnabledProperty property.
IsAnimationEnabledWhenScrollToASpecificChildIndexProperty
IsAnimationEnabledForDeterministicScrollToASpecificChildIndexProperty property.
IsDataSourceGroupedProperty
Gets or sets whether the data source of the items control is set up with grouping information.
IsDynamicConstructionCapabilityEnabledProperty
The is dynamic construction capability enabled property
IsExtraMarginAtStartupRequiredProperty
The is extra margin at startup required property
IsRenderItemDimensionHeightSpacingBetweenGroupHeaderAndDataItemRowEnabledProperty
The is render item dimension height spacing between group header and data item row enabled property
IsTrimExtraLinkbreakForFirstRowEnabledProperty
The is trim extra linkbreak for first row enabled property
IsVariableItemSizeEnabledProperty
Identifies the IsVariableItemSizeEnabled dependency property.
ItemDimensionProperty
ItemDimensionProperty property.
Value. The size of the item.
ItemPositioningModeProperty
The item positioning mode property
OrientationProperty
OrientationProperty property.
PanelAnimationEffectProperty
PanelAnimationEffectProperty property.
ReRenderVisibilityRangeMaxCountProperty
The re render visibility range maximum count property
RendertimeMarginProperty
The rendertime margin property
ShouldAutoAdjustParentItemsControlInternalPaddingProperty
Identifies the ShouldAutoAdjustParentItemsControlInternalPadding dependency property.
ShouldRenderExtraLineBeforeHeaderProperty
Gets or sets a value indicating whether the control should render an extra line before header in standalone line rendering mode.
ShouldRenderItemHeightSpacingAfterAGroupHasBeenRenderedProperty
The should render item height spacing after a group has been rendered property
VirtualizationSchemeOptionProperty
VirtualizationSchemeOptionProperty property.
VirtualizationSchemeWhenScrollingToASpecificChildIndexProperty
VirtualizationSchemeWhenScrollingToASpecificChildIndexProperty property.