Fixing recursive setting of source and target value when converters are used in both directions.
This commit is contained in:
Родитель
8c303b19ab
Коммит
67f716044a
|
@ -833,7 +833,9 @@ namespace GalaSoft.MvvmLight.Helpers
|
|||
&& _propertyTarget.IsAlive
|
||||
&& _propertyTarget.Target != null)
|
||||
{
|
||||
_settingSourceToTarget = true;
|
||||
SetTargetValue(value);
|
||||
_settingSourceToTarget = false;
|
||||
}
|
||||
|
||||
if (_onSourceUpdate != null
|
||||
|
@ -1128,7 +1130,8 @@ namespace GalaSoft.MvvmLight.Helpers
|
|||
&& _propertyTarget.Target != null
|
||||
&& _propertySource != null
|
||||
&& _propertySource.IsAlive
|
||||
&& _propertySource.Target != null)
|
||||
&& _propertySource.Target != null
|
||||
&& !_settingTargetToSource)
|
||||
{
|
||||
var valueLocal = GetSourceValue();
|
||||
var targetValue = _targetProperty.GetValue(_propertyTarget.Target, null);
|
||||
|
@ -1140,7 +1143,9 @@ namespace GalaSoft.MvvmLight.Helpers
|
|||
|
||||
if (_targetProperty != null)
|
||||
{
|
||||
_settingSourceToTarget = true;
|
||||
SetTargetValue(valueLocal);
|
||||
_settingSourceToTarget = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1159,7 +1164,8 @@ namespace GalaSoft.MvvmLight.Helpers
|
|||
&& _propertyTarget.Target != null
|
||||
&& _propertySource != null
|
||||
&& _propertySource.IsAlive
|
||||
&& _propertySource.Target != null)
|
||||
&& _propertySource.Target != null
|
||||
&& !_settingSourceToTarget)
|
||||
{
|
||||
var valueLocal = GetTargetValue();
|
||||
var sourceValue = _sourceProperty.GetValue(_propertySource.Target, null);
|
||||
|
@ -1169,7 +1175,9 @@ namespace GalaSoft.MvvmLight.Helpers
|
|||
return;
|
||||
}
|
||||
|
||||
_settingTargetToSource = true;
|
||||
SetSourceValue(valueLocal);
|
||||
_settingTargetToSource = false;
|
||||
}
|
||||
|
||||
RaiseValueChanged();
|
||||
|
|
|
@ -92,6 +92,7 @@
|
|||
<Compile Include="Binding\BindingTargetTest.cs" />
|
||||
<Compile Include="Binding\BindingSourceTest.cs" />
|
||||
<Compile Include="Binding\BindingTest.cs" />
|
||||
<Compile Include="Binding\ConverterTest.cs" />
|
||||
<Compile Include="Binding\SetCommandTest.cs" />
|
||||
<Compile Include="Binding\ObserveEventImplicitTest.cs" />
|
||||
<Compile Include="Binding\ObserveEventLostFocusTest.cs" />
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using System.Windows.Input;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
|
||||
|
@ -6,6 +7,8 @@ namespace GalaSoft.MvvmLight.Test.ViewModel
|
|||
public class TestViewModel : ViewModelBase
|
||||
{
|
||||
public const string ValueForCommand = "Command value";
|
||||
|
||||
private DateTime _date;
|
||||
private TestModel _model;
|
||||
private TestViewModel _nested;
|
||||
private string _propertyValue;
|
||||
|
@ -13,6 +16,18 @@ namespace GalaSoft.MvvmLight.Test.ViewModel
|
|||
private RelayCommand _setPropertyWithoutValueCommand;
|
||||
private ICommand _testCommandImpl;
|
||||
|
||||
public DateTime Date
|
||||
{
|
||||
get
|
||||
{
|
||||
return _date;
|
||||
}
|
||||
set
|
||||
{
|
||||
Set(ref _date, value);
|
||||
}
|
||||
}
|
||||
|
||||
public TestModel Model
|
||||
{
|
||||
get
|
||||
|
|
|
@ -141,6 +141,9 @@
|
|||
<Compile Include="..\AndroidTestApp\Binding\BindingTest.cs">
|
||||
<Link>Binding\BindingTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\AndroidTestApp\Binding\ConverterTest.cs">
|
||||
<Link>Binding\ConverterTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\AndroidTestApp\ViewModel\AccountModel.cs">
|
||||
<Link>ViewModel\AccountModel.cs</Link>
|
||||
</Compile>
|
||||
|
|
Загрузка…
Ссылка в новой задаче