We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

RangeSliderControl databinding not working

Hi,

I want to bind a RangeSliderControl Value or Range to the datacontext and it doesn't seem to work and I can't find an example in the online docs.  In the attached example, I have a simple model with 2 properties, a double and a DoubleRange.  Then I have a label, a traditional Microsoft Slider, a RangeSliderControl bound to the double in my model, and a RangeSliderControl bound to the DoubleRange in my model.  The label and slider work as expected, but the RangeSliderControls don't participate in the binding and there are no binding errors in the output window.

Any ideas?

--Jonathan

Here is my XAML for the 4 databound controls:

 <StackPanel>
        <Label Content="{Binding Path=SliderValue}" Height="28" />
        <Slider Value="{Binding Path=SliderValue}" Width="100" />
        <syncfusion:RangeSliderControl Height="100" Maximum="10" TickFrequency="1" Value="{Binding Path=SliderValue}"></syncfusion:RangeSliderControl>
        <syncfusion:RangeSliderControl Height="100" Maximum="10" TickFrequency="1" Range="{Binding Path=SliderRange}"></syncfusion:RangeSliderControl>
    </StackPanel>

And the code for my model:

class Model : INotifyPropertyChanged
    {
        private double sliderValue;

        public double SliderValue
        {
            get { return sliderValue; }
            set
            {
                sliderValue = value;
                Change("SliderValue");
            }
        }

        public DoubleRange SliderRange
        {
            get
            {
                return new DoubleRange(0, SliderValue);
            }

            set
            {
                SliderValue = value.End;
                Change("SliderRange");
            }
        }

        #region INotitifyPropertyChanged

        public event PropertyChangedEventHandler PropertyChanged;

        protected void Change(string field)
        {
            var pc = PropertyChanged;
            if (pc != null)
            {
                pc.Invoke(this, new PropertyChangedEventArgs(field));
            }
        }

        #endregion


1 Reply

MM Muthalagu M Syncfusion Team August 14, 2012 07:00 AM UTC

Hi Jonathan,

Sorry for the delay in getting back to you.

Thanks for using Syncfusion Products.

We have prepared a sample for RangeSlider Control with DataBinding and we have attached the sample.Please find this.

In this sample, we have acheived this DataBinding with RangeSlider in following way.

We have used RangeVisibiltiy property and it is set to False for binding the SliderValue.

Also we have made changes in SliderRange property to bind the values correctly.

Please let us know in case of any queries.

Regards,

Muthalagu



RangeSliderControlDataBinding104630Demo_1966854a.zip

Loader.
Live Chat Icon For mobile
Up arrow icon