Browse Source

Simplified conditions

pull/4871/head
Yoh Deadfall 6 years ago
parent
commit
cdb4e90518
  1. 20
      src/Avalonia.Controls/Primitives/SelectingItemsControl.cs

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

@ -794,18 +794,13 @@ namespace Avalonia.Controls.Primitives
/// <param name="e">The event.</param> /// <param name="e">The event.</param>
private void ContainerSelectionChanged(RoutedEventArgs e) private void ContainerSelectionChanged(RoutedEventArgs e)
{ {
if (!_ignoreContainerSelectionChanged) if (!_ignoreContainerSelectionChanged &&
e.Source is IControl control &&
e.Source is ISelectable selectable &&
control.LogicalParent == this &&
ItemContainerGenerator?.IndexFromContainer(control) != -1)
{ {
var control = e.Source as IControl; UpdateSelection(control, selectable.IsSelected);
var selectable = e.Source as ISelectable;
if (control != null &&
selectable != null &&
control.LogicalParent == this &&
ItemContainerGenerator?.IndexFromContainer(control) != -1)
{
UpdateSelection(control, selectable.IsSelected);
}
} }
if (e.Source != this) if (e.Source != this)
@ -824,12 +819,11 @@ namespace Avalonia.Controls.Primitives
{ {
try try
{ {
var selectable = container as ISelectable;
bool result; bool result;
_ignoreContainerSelectionChanged = true; _ignoreContainerSelectionChanged = true;
if (selectable != null) if (container is ISelectable selectable)
{ {
result = selectable.IsSelected; result = selectable.IsSelected;
selectable.IsSelected = selected; selectable.IsSelected = selected;

Loading…
Cancel
Save