Browse Source
Merge pull request #7786 from timunie/fix/DataGridCopyClearsContent
Fix: DataGrid copying data clears DataGridCells
pull/7853/head
Max Katz
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
37 additions and
7 deletions
-
src/Avalonia.Base/Data/BindingOperations.cs
-
tests/Avalonia.Base.UnitTests/AvaloniaObjectTests_Binding.cs
|
|
|
@ -99,14 +99,15 @@ namespace Avalonia.Data |
|
|
|
|
|
|
|
private sealed class TwoWayBindingDisposable : IDisposable |
|
|
|
{ |
|
|
|
private readonly IDisposable _first; |
|
|
|
private readonly IDisposable _second; |
|
|
|
private readonly IDisposable _toTargetSubscription; |
|
|
|
private readonly IDisposable _fromTargetSubsription; |
|
|
|
|
|
|
|
private bool _isDisposed; |
|
|
|
|
|
|
|
public TwoWayBindingDisposable(IDisposable first, IDisposable second) |
|
|
|
public TwoWayBindingDisposable(IDisposable toTargetSubscription, IDisposable fromTargetSubsription) |
|
|
|
{ |
|
|
|
_first = first; |
|
|
|
_second = second; |
|
|
|
_toTargetSubscription = toTargetSubscription; |
|
|
|
_fromTargetSubsription = fromTargetSubsription; |
|
|
|
} |
|
|
|
|
|
|
|
public void Dispose() |
|
|
|
@ -116,8 +117,8 @@ namespace Avalonia.Data |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
_first.Dispose(); |
|
|
|
_second.Dispose(); |
|
|
|
_fromTargetSubsription.Dispose(); |
|
|
|
_toTargetSubscription.Dispose(); |
|
|
|
|
|
|
|
_isDisposed = true; |
|
|
|
} |
|
|
|
|
|
|
|
@ -829,6 +829,30 @@ namespace Avalonia.Base.UnitTests |
|
|
|
subscription.Dispose(); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void TwoWay_Binding_Should_Not_Call_Setter_On_Creation_With_Value() |
|
|
|
{ |
|
|
|
var target = new Class1(); |
|
|
|
var source = new TestTwoWayBindingViewModel() { Value = 1 }; |
|
|
|
source.ResetSetterCalled(); |
|
|
|
|
|
|
|
target.Bind(Class1.DoubleValueProperty, new Binding(nameof(source.Value), BindingMode.TwoWay) { Source = source }); |
|
|
|
|
|
|
|
Assert.False(source.SetterCalled); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void TwoWay_Binding_Should_Not_Call_Setter_On_Creation_Indexer_With_Value() |
|
|
|
{ |
|
|
|
var target = new Class1(); |
|
|
|
var source = new TestTwoWayBindingViewModel() { [0] = 1 }; |
|
|
|
source.ResetSetterCalled(); |
|
|
|
|
|
|
|
target.Bind(Class1.DoubleValueProperty, new Binding("[0]", BindingMode.TwoWay) { Source = source }); |
|
|
|
|
|
|
|
Assert.False(source.SetterCalled); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Returns an observable that returns a single value but does not complete.
|
|
|
|
/// </summary>
|
|
|
|
@ -943,6 +967,11 @@ namespace Avalonia.Base.UnitTests |
|
|
|
} |
|
|
|
|
|
|
|
public bool SetterCalled { get; private set; } |
|
|
|
|
|
|
|
public void ResetSetterCalled() |
|
|
|
{ |
|
|
|
SetterCalled = false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|