Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Avalonia.Controls/Primitives/SelectingItemsControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -871,8 +871,8 @@ private void SelectedItemsCollectionChanged(object sender, NotifyCollectionChang
RaisePropertyChanged(SelectedItemProperty, oldItem, item, BindingPriority.LocalValue);
}

added = e.OldItems;
removed = e.NewItems;
added = e.NewItems;
removed = e.OldItems;
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,35 @@ public void Assigning_SelectedItems_Should_Raise_SelectionChanged()
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 =>
Expand Down