Browse Source
Merge pull request #3227 from AvaloniaUI/fix-listbox-template-init-order
set Scroll before calling base.OnTemplateApplied.
pull/3230/head
danwalmsley
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
21 additions and
1 deletions
-
src/Avalonia.Controls/ListBox.cs
-
tests/Avalonia.Controls.UnitTests/ListBoxTests.cs
|
|
|
@ -151,8 +151,8 @@ namespace Avalonia.Controls |
|
|
|
|
|
|
|
protected override void OnTemplateApplied(TemplateAppliedEventArgs e) |
|
|
|
{ |
|
|
|
base.OnTemplateApplied(e); |
|
|
|
Scroll = e.NameScope.Find<IScrollable>("PART_ScrollViewer"); |
|
|
|
base.OnTemplateApplied(e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -47,6 +47,26 @@ namespace Avalonia.Controls.UnitTests |
|
|
|
Assert.IsType<ItemsPresenter>(target.Presenter); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void ListBox_Should_Find_Scrollviewer_In_Template() |
|
|
|
{ |
|
|
|
var target = new ListBox |
|
|
|
{ |
|
|
|
Template = ListBoxTemplate(), |
|
|
|
}; |
|
|
|
|
|
|
|
ScrollViewer viewer = null; |
|
|
|
|
|
|
|
target.TemplateApplied += (sender, e) => |
|
|
|
{ |
|
|
|
viewer = target.Scroll as ScrollViewer; |
|
|
|
}; |
|
|
|
|
|
|
|
Prepare(target); |
|
|
|
|
|
|
|
Assert.NotNull(viewer); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void ListBoxItem_Containers_Should_Be_Generated() |
|
|
|
{ |
|
|
|
|