52 lines
1.7 KiB
C#
52 lines
1.7 KiB
C#
|
|
|
|
|
|
/* Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license.
|
|
https://github.com/sbaeumlisberger/VirtualizingWrapPanel
|
|
Copyright (C) S. Bäumlisberger
|
|
All Rights Reserved. */
|
|
|
|
using System.Windows.Controls;
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
namespace WPFluent.Controls;
|
|
|
|
/// <summary>
|
|
/// Virtualized <see cref="ItemsControl"/>. <para>Based on <see
|
|
/// href="https://github.com/sbaeumlisberger/VirtualizingWrapPanel"/>.</para>
|
|
/// </summary>
|
|
public class VirtualizingItemsControl : ItemsControl
|
|
{
|
|
/// <summary>
|
|
/// Identifies the <see cref="CacheLengthUnit"/> dependency property.
|
|
/// </summary>
|
|
public static readonly DependencyProperty CacheLengthUnitProperty = DependencyProperty.Register(
|
|
nameof(CacheLengthUnit),
|
|
typeof(VirtualizationCacheLengthUnit),
|
|
typeof(VirtualizingItemsControl),
|
|
new FrameworkPropertyMetadata(VirtualizationCacheLengthUnit.Page));
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="VirtualizingItemsControl"/> class.
|
|
/// </summary>
|
|
public VirtualizingItemsControl()
|
|
{
|
|
VirtualizingPanel.SetCacheLengthUnit(this, CacheLengthUnit);
|
|
VirtualizingPanel.SetCacheLength(this, new VirtualizationCacheLength(1));
|
|
VirtualizingPanel.SetIsVirtualizingWhenGrouping(this, true);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the cache length unit.
|
|
/// </summary>
|
|
public VirtualizationCacheLengthUnit CacheLengthUnit
|
|
{
|
|
get => VirtualizingPanel.GetCacheLengthUnit(this);
|
|
set
|
|
{
|
|
SetValue(CacheLengthUnitProperty, value);
|
|
VirtualizingPanel.SetCacheLengthUnit(this, value);
|
|
}
|
|
}
|
|
}
|