|
|
@ -17,6 +17,7 @@ namespace Avalonia.Controls |
|
|
{ |
|
|
{ |
|
|
private readonly SelectionNode _rootNode; |
|
|
private readonly SelectionNode _rootNode; |
|
|
private bool _singleSelect; |
|
|
private bool _singleSelect; |
|
|
|
|
|
private int _operationCount; |
|
|
private IReadOnlyList<IndexPath>? _selectedIndicesCached; |
|
|
private IReadOnlyList<IndexPath>? _selectedIndicesCached; |
|
|
private IReadOnlyList<object?>? _selectedItemsCached; |
|
|
private IReadOnlyList<object?>? _selectedItemsCached; |
|
|
private SelectionModelChildrenRequestedEventArgs? _childrenRequestedEventArgs; |
|
|
private SelectionModelChildrenRequestedEventArgs? _childrenRequestedEventArgs; |
|
|
@ -509,6 +510,8 @@ namespace Avalonia.Controls |
|
|
ClearSelection(resetAnchor: true); |
|
|
ClearSelection(resetAnchor: true); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public IDisposable Update() => new Operation(this); |
|
|
|
|
|
|
|
|
protected void OnPropertyChanged(string propertyName) |
|
|
protected void OnPropertyChanged(string propertyName) |
|
|
{ |
|
|
{ |
|
|
RaisePropertyChanged(propertyName); |
|
|
RaisePropertyChanged(propertyName); |
|
|
@ -732,19 +735,33 @@ namespace Avalonia.Controls |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void BeginOperation() => _rootNode.BeginOperation(); |
|
|
private void BeginOperation() |
|
|
|
|
|
{ |
|
|
|
|
|
if (_operationCount++ == 0) |
|
|
|
|
|
{ |
|
|
|
|
|
_rootNode.BeginOperation(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private void EndOperation() |
|
|
private void EndOperation() |
|
|
{ |
|
|
{ |
|
|
var changes = new List<SelectionNodeOperation>(); |
|
|
if (_operationCount == 0) |
|
|
_rootNode.EndOperation(changes); |
|
|
{ |
|
|
|
|
|
throw new AvaloniaInternalException("No selection operation in progress."); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
SelectionModelSelectionChangedEventArgs? e = null; |
|
|
SelectionModelSelectionChangedEventArgs? e = null; |
|
|
|
|
|
|
|
|
if (changes.Count > 0) |
|
|
if (--_operationCount == 0) |
|
|
{ |
|
|
{ |
|
|
var changeSet = new SelectionModelChangeSet(changes); |
|
|
var changes = new List<SelectionNodeOperation>(); |
|
|
e = changeSet.CreateEventArgs(); |
|
|
_rootNode.EndOperation(changes); |
|
|
|
|
|
|
|
|
|
|
|
if (changes.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
var changeSet = new SelectionModelChangeSet(changes); |
|
|
|
|
|
e = changeSet.CreateEventArgs(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
OnSelectionChanged(e); |
|
|
OnSelectionChanged(e); |
|
|
|