Browse Source
Merge pull request #11782 from AvaloniaUI/fixes/11617-change-selection-in-selection-changed
Fix changing selection source in selection changed
pull/11798/head
Max Katz
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with
37 additions and
1 deletions
-
.ncrunch/MobileSandbox.Browser.v3.ncrunchproject
-
.ncrunch/WindowsInteropTest.net461.v3.ncrunchproject
-
.ncrunch/WindowsInteropTest.net6.0-windows.v3.ncrunchproject
-
src/Avalonia.Controls/Selection/SelectionModel.cs
-
tests/Avalonia.Controls.UnitTests/Selection/SelectionModelTests_Single.cs
|
|
|
@ -0,0 +1,5 @@ |
|
|
|
<ProjectConfiguration> |
|
|
|
<Settings> |
|
|
|
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|
|
|
</Settings> |
|
|
|
</ProjectConfiguration> |
|
|
|
@ -0,0 +1,5 @@ |
|
|
|
<ProjectConfiguration> |
|
|
|
<Settings> |
|
|
|
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|
|
|
</Settings> |
|
|
|
</ProjectConfiguration> |
|
|
|
@ -0,0 +1,5 @@ |
|
|
|
<ProjectConfiguration> |
|
|
|
<Settings> |
|
|
|
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|
|
|
</Settings> |
|
|
|
</ProjectConfiguration> |
|
|
|
@ -277,7 +277,7 @@ namespace Avalonia.Controls.Selection |
|
|
|
{ |
|
|
|
if (base.Source != value) |
|
|
|
{ |
|
|
|
if (_operation is not null) |
|
|
|
if (_operation?.UpdateCount > 0) |
|
|
|
{ |
|
|
|
throw new InvalidOperationException("Cannot change source while update is in progress."); |
|
|
|
} |
|
|
|
|
|
|
|
@ -300,6 +300,27 @@ namespace Avalonia.Controls.UnitTests.Selection |
|
|
|
|
|
|
|
target.Source = new[] { 1, 2, 3 }; |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Can_Change_Source_In_SelectedItem_Change_Handler() |
|
|
|
{ |
|
|
|
// Issue #11617
|
|
|
|
var target = CreateTarget(); |
|
|
|
var raised = 0; |
|
|
|
|
|
|
|
target.PropertyChanged += (s, e) => |
|
|
|
{ |
|
|
|
if (e.PropertyName == nameof(target.SelectedItem) && raised == 0) |
|
|
|
{ |
|
|
|
++raised; |
|
|
|
target.Source = new[] { "foo", "baz", "bar" }; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
target.SelectedIndex = 1; |
|
|
|
|
|
|
|
Assert.Equal(-1, target.SelectedIndex); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public class SelectedIndex |
|
|
|
|