Hi,
I'm trying somethin trivial, having a rangeslider and numericupdown linked to the same backing property. If the slider is moved, the numericupdown should move too and vice versa. I'm using the MVVM approach so it has to be set in the ViewModel.
Attempt 1 : Binding it to the same property in viewmodel. This does not work at all, unable to slide the slider, it cannot move.
Attempt 2 : Having each their own property and keep them in sync in the model. See example below with line is linked to slider and spin is linked to numeric updown. This works partially, if you change the updow, the slider moves too. However if you my the slider, the app stops responding and keeps entering in set of CurrentValueLine.
Any suggestions ?
Regards,
Sven Peeters
public int CurrentValueLine { get => currentValueLine;
set
{
if (value == currentValueLine)
return;
currentValueLine = value;
OnPropertyChanged();
if (currentValueLine != currentValueSpin)
{
currentValueSpin = currentValueLine;
OnPropertyChanged(nameof(CurrentValueSpin));
}
}
}
public int CurrentValueSpin
{
get => currentValueSpin;
set
{
if (value == currentValueSpin)
return;
currentValueSpin = value;
OnPropertyChanged();
if (currentValueSpin != currentValueLine)
{
currentValueLine = currentValueSpin;
OnPropertyChanged(nameof(CurrentValueLine));
}
}
}
Hi,
I found the solution a few days ago, I removed the OnPropertyChanged() in my CurrentValueLine property.
I guess it was getting confused since both properties are linked to each other.