From e930c358827e95eb8e1de94289848d01bd4d571c Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Tue, 24 May 2016 11:57:40 +0200 Subject: [PATCH] Expose IScrollable in ListBox. To allow programmatic control of the ListBox's scroll. --- src/Avalonia.Controls/ListBox.cs | 14 +++++++++++--- src/Avalonia.Themes.Default/ListBox.xaml | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) 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 @@ - +