combine rangeslider and numericup down

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));

                }

            }

        }




3 Replies

SS Suganya Sethuraman Syncfusion Team February 11, 2022 11:53 AM UTC

Hi Sven,

Since we are unable to reproduce the reported issue, we would like you to check the issue with the attached sample and let us know if it is reproduced. Else, please revert to us by modifying the sample based on your application and provide the replication procedure or the sample. It will be helpful for us to provide a better solution at the earliest.

Sample:  https://www.syncfusion.com/downloads/support/directtrac/general/ze/RangeNumericSample-65688926

Regards,
Suganya Sethuraman.
 



SV Sven February 18, 2022 01:13 AM UTC

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.



SS Suganya Sethuraman Syncfusion Team February 18, 2022 09:55 AM UTC

Hi Sven,

Thanks for the update.

We are glad that your issue is resolved. Please let us know if you require any further assistance.

Regards,
Suganya Sethuraman.
 


Loader.
Up arrow icon