Browse Source

Merge branch 'master' into windowing-prototype

windowing-prototype
danwalmsley 7 years ago
committed by GitHub
parent
commit
02b91a623e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/Avalonia.Controls/Primitives/SelectingItemsControl.cs
  2. 29
      tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests_Multiple.cs

4
src/Avalonia.Controls/Primitives/SelectingItemsControl.cs

@ -871,8 +871,8 @@ namespace Avalonia.Controls.Primitives
RaisePropertyChanged(SelectedItemProperty, oldItem, item, BindingPriority.LocalValue); RaisePropertyChanged(SelectedItemProperty, oldItem, item, BindingPriority.LocalValue);
} }
added = e.OldItems; added = e.NewItems;
removed = e.NewItems; removed = e.OldItems;
break; break;
} }

29
tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests_Multiple.cs

@ -541,6 +541,35 @@ namespace Avalonia.Controls.UnitTests.Primitives
Assert.True(called); 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() private FuncControlTemplate Template()
{ {
return new FuncControlTemplate<SelectingItemsControl>(control => return new FuncControlTemplate<SelectingItemsControl>(control =>

Loading…
Cancel
Save