Browse Source

Make restored tests pass.

pull/4533/head
Steven Kirk 6 years ago
parent
commit
10b03b15ec
  1. 50
      src/Avalonia.Controls/Primitives/SelectingItemsControl.cs

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

@ -199,8 +199,18 @@ namespace Avalonia.Controls.Primitives
"collection is different to the Items on the control."); "collection is different to the Items on the control.");
} }
var oldSelection = _selection?.SelectedItems.ToList();
DeinitializeSelectionModel(_selection); DeinitializeSelectionModel(_selection);
_selection = value; _selection = value;
if (oldSelection?.Count > 0)
{
RaiseEvent(new SelectionChangedEventArgs(
SelectionChangedEvent,
oldSelection,
Array.Empty<object>()));
}
InitializeSelectionModel(_selection); InitializeSelectionModel(_selection);
} }
} }
@ -786,37 +796,15 @@ namespace Avalonia.Controls.Primitives
model.SelectedIndex = 0; model.SelectedIndex = 0;
} }
//if (Items is INotifyCollectionChanged incc) UpdateContainerSelection();
//{
// // At this point we can be sure that SelectionModel has subscribed to collection if (SelectedIndex != -1)
// // changes. {
// incc.CollectionChanged += AfterItemsCollectionChanged; RaiseEvent(new SelectionChangedEventArgs(
//} SelectionChangedEvent,
Array.Empty<object>(),
//UpdateContainerSelection(); Selection.SelectedItems.ToList()));
}
//var selectedIndex = SelectedIndex;
//var selectedItem = SelectedItem;
//if (_selectedIndex != selectedIndex)
//{
// RaisePropertyChanged(SelectedIndexProperty, _selectedIndex, selectedIndex);
// _selectedIndex = selectedIndex;
//}
//if (_selectedItem != selectedItem)
//{
// RaisePropertyChanged(SelectedItemProperty, _selectedItem, selectedItem);
// _selectedItem = selectedItem;
//}
//if (selectedIndex != -1)
//{
// RaiseEvent(new SelectionChangedEventArgs(
// SelectionChangedEvent,
// Array.Empty<object>(),
// Selection.SelectedItems.ToList()));
//}
} }
private void DeinitializeSelectionModel(ISelectionModel? model) private void DeinitializeSelectionModel(ISelectionModel? model)

Loading…
Cancel
Save