|
|
@ -33,31 +33,38 @@ namespace Avalonia.Controls |
|
|
|
|
|
|
|
|
public object? Source |
|
|
public object? Source |
|
|
{ |
|
|
{ |
|
|
get => _rootNode?.Source; |
|
|
get => _rootNode.Source; |
|
|
set |
|
|
set |
|
|
{ |
|
|
{ |
|
|
var wasNull = _rootNode.Source == null; |
|
|
if (_rootNode.Source != value) |
|
|
|
|
|
|
|
|
if (_rootNode.Source != null) |
|
|
|
|
|
{ |
|
|
{ |
|
|
using (var operation = new Operation(this)) |
|
|
var wasNull = _rootNode.Source == null; |
|
|
|
|
|
|
|
|
|
|
|
if (_rootNode.Source != null) |
|
|
{ |
|
|
{ |
|
|
ClearSelection(resetAnchor: true); |
|
|
using (var operation = new Operation(this)) |
|
|
|
|
|
{ |
|
|
|
|
|
ClearSelection(resetAnchor: true); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_rootNode.Source = value; |
|
|
_rootNode.Source = value; |
|
|
|
|
|
|
|
|
RaisePropertyChanged("Source"); |
|
|
RaisePropertyChanged("Source"); |
|
|
|
|
|
|
|
|
if (wasNull) |
|
|
if (wasNull) |
|
|
{ |
|
|
{ |
|
|
var e = new SelectionModelSelectionChangedEventArgs( |
|
|
var e = new SelectionModelSelectionChangedEventArgs( |
|
|
null, |
|
|
null, |
|
|
SelectedIndices, |
|
|
SelectedIndices, |
|
|
null, |
|
|
null, |
|
|
SelectedItems); |
|
|
SelectedItems); |
|
|
OnSelectionChanged(e); |
|
|
OnSelectionChanged(e); |
|
|
|
|
|
ClearSelection(resetAnchor: true); |
|
|
|
|
|
_rootNode.Source = value; |
|
|
|
|
|
OnSelectionChanged(); |
|
|
|
|
|
RaisePropertyChanged("Source"); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -101,7 +108,7 @@ namespace Avalonia.Controls |
|
|
{ |
|
|
{ |
|
|
IndexPath anchor = default; |
|
|
IndexPath anchor = default; |
|
|
|
|
|
|
|
|
if (_rootNode?.AnchorIndex >= 0) |
|
|
if (_rootNode.AnchorIndex >= 0) |
|
|
{ |
|
|
{ |
|
|
var path = new List<int>(); |
|
|
var path = new List<int>(); |
|
|
SelectionNode? current = _rootNode; |
|
|
SelectionNode? current = _rootNode; |
|
|
@ -322,7 +329,7 @@ namespace Avalonia.Controls |
|
|
public void Dispose() |
|
|
public void Dispose() |
|
|
{ |
|
|
{ |
|
|
ClearSelection(resetAnchor: false); |
|
|
ClearSelection(resetAnchor: false); |
|
|
_rootNode?.Dispose(); |
|
|
_rootNode.Dispose(); |
|
|
_selectedIndicesCached = null; |
|
|
_selectedIndicesCached = null; |
|
|
_selectedItemsCached = null; |
|
|
_selectedItemsCached = null; |
|
|
} |
|
|
} |
|
|
|