Browse Source
Merge branch 'master' into windowing-prototype
windowing-prototype
danwalmsley
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
31 additions and
2 deletions
-
src/Avalonia.Controls/Primitives/SelectingItemsControl.cs
-
tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests_Multiple.cs
|
|
|
@ -871,8 +871,8 @@ namespace Avalonia.Controls.Primitives |
|
|
|
RaisePropertyChanged(SelectedItemProperty, oldItem, item, BindingPriority.LocalValue); |
|
|
|
} |
|
|
|
|
|
|
|
added = e.OldItems; |
|
|
|
removed = e.NewItems; |
|
|
|
added = e.NewItems; |
|
|
|
removed = e.OldItems; |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -541,6 +541,35 @@ namespace Avalonia.Controls.UnitTests.Primitives |
|
|
|
Assert.True(called); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Replacing_SelectedItems_Should_Raise_SelectionChanged_With_CorrectItems() |
|
|
|
{ |
|
|
|
var items = new[] { "foo", "bar", "baz" }; |
|
|
|
|
|
|
|
var target = new TestSelector |
|
|
|
{ |
|
|
|
Items = items, |
|
|
|
Template = Template(), |
|
|
|
SelectedItem = "bar", |
|
|
|
}; |
|
|
|
|
|
|
|
var called = false; |
|
|
|
|
|
|
|
target.SelectionChanged += (s, e) => |
|
|
|
{ |
|
|
|
Assert.Equal(new[] { "foo",}, e.AddedItems.Cast<object>()); |
|
|
|
Assert.Equal(new[] { "bar" }, e.RemovedItems.Cast<object>()); |
|
|
|
called = true; |
|
|
|
}; |
|
|
|
|
|
|
|
target.ApplyTemplate(); |
|
|
|
target.Presenter.ApplyTemplate(); |
|
|
|
target.SelectedItems[0] = "foo"; |
|
|
|
|
|
|
|
Assert.True(called); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private FuncControlTemplate Template() |
|
|
|
{ |
|
|
|
return new FuncControlTemplate<SelectingItemsControl>(control => |
|
|
|
|