diff --git a/src/Avalonia.Controls/ListBox.cs b/src/Avalonia.Controls/ListBox.cs index f61e2fa8d3..95c980974b 100644 --- a/src/Avalonia.Controls/ListBox.cs +++ b/src/Avalonia.Controls/ListBox.cs @@ -2,13 +2,10 @@ // Licensed under the MIT license. See licence.md file in the project root for full license information. using System.Collections; -using System.Collections.Generic; -using Avalonia.Collections; using Avalonia.Controls.Generators; using Avalonia.Controls.Primitives; using Avalonia.Controls.Templates; using Avalonia.Input; -using Avalonia.Interactivity; namespace Avalonia.Controls { @@ -43,6 +40,11 @@ namespace Avalonia.Controls ItemsPanelProperty.OverrideDefaultValue(DefaultPanel); } + /// + /// Gets the scroll information for the . + /// + public IScrollable Scroll { get; set; } + /// public new IList SelectedItems => base.SelectedItems; @@ -90,5 +92,11 @@ namespace Avalonia.Controls (e.InputModifiers & InputModifiers.Control) != 0); } } + + protected override void OnTemplateApplied(TemplateAppliedEventArgs e) + { + base.OnTemplateApplied(e); + Scroll = e.NameScope.Find("PART_ScrollViewer"); + } } } diff --git a/src/Avalonia.Themes.Default/ListBox.xaml b/src/Avalonia.Themes.Default/ListBox.xaml index 782cc36107..9454f3eb31 100644 --- a/src/Avalonia.Themes.Default/ListBox.xaml +++ b/src/Avalonia.Themes.Default/ListBox.xaml @@ -7,7 +7,7 @@ - +