diff --git a/src/Avalonia.Controls/DropDown.cs b/src/Avalonia.Controls/DropDown.cs
index a30cc231b7..d17089c127 100644
--- a/src/Avalonia.Controls/DropDown.cs
+++ b/src/Avalonia.Controls/DropDown.cs
@@ -4,8 +4,10 @@
using System;
using System.Linq;
using Avalonia.Controls.Generators;
+using Avalonia.Controls.Presenters;
using Avalonia.Controls.Primitives;
using Avalonia.Controls.Shapes;
+using Avalonia.Controls.Templates;
using Avalonia.Input;
using Avalonia.LogicalTree;
using Avalonia.Media;
@@ -13,12 +15,17 @@ using Avalonia.VisualTree;
namespace Avalonia.Controls
{
-
///
/// A drop-down list control.
///
public class DropDown : SelectingItemsControl
{
+ ///
+ /// The default value for the property.
+ ///
+ private static readonly FuncTemplate DefaultPanel =
+ new FuncTemplate(() => new VirtualizingStackPanel());
+
///
/// Defines the property.
///
@@ -40,6 +47,12 @@ namespace Avalonia.Controls
public static readonly DirectProperty SelectionBoxItemProperty =
AvaloniaProperty.RegisterDirect(nameof(SelectionBoxItem), o => o.SelectionBoxItem);
+ ///
+ /// Defines the property.
+ ///
+ public static readonly StyledProperty VirtualizationModeProperty =
+ ItemsPresenter.VirtualizationModeProperty.AddOwner();
+
private bool _isDropDownOpen;
private Popup _popup;
private object _selectionBoxItem;
@@ -49,6 +62,7 @@ namespace Avalonia.Controls
///
static DropDown()
{
+ ItemsPanelProperty.OverrideDefaultValue(DefaultPanel);
FocusableProperty.OverrideDefaultValue(true);
SelectedItemProperty.Changed.AddClassHandler(x => x.SelectedItemChanged);
KeyDownEvent.AddClassHandler(x => x.OnKeyDown, Interactivity.RoutingStrategies.Tunnel);
@@ -81,6 +95,15 @@ namespace Avalonia.Controls
set { SetAndRaise(SelectionBoxItemProperty, ref _selectionBoxItem, value); }
}
+ ///
+ /// Gets or sets the virtualization mode for the items.
+ ///
+ public ItemVirtualizationMode VirtualizationMode
+ {
+ get { return GetValue(VirtualizationModeProperty); }
+ set { SetValue(VirtualizationModeProperty, value); }
+ }
+
///
protected override IItemContainerGenerator CreateItemContainerGenerator()
{
diff --git a/src/Avalonia.Themes.Default/DropDown.xaml b/src/Avalonia.Themes.Default/DropDown.xaml
index 4684e1c872..9603bba107 100644
--- a/src/Avalonia.Themes.Default/DropDown.xaml
+++ b/src/Avalonia.Themes.Default/DropDown.xaml
@@ -42,8 +42,11 @@
+ MemberSelector="{TemplateBinding MemberSelector}"
+ VirtualizationMode="{TemplateBinding VirtualizationMode}"
+ />