Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > Slider > Selection start/end jump when changing binding value in codebehind

Not answered Selection start/end jump when changing binding value in codebehind

Feed from this thread
  • Derek avatar

    Posted on Nov 9, 2011 (permalink)

    I am using the RadSlider in Silverlight with properties set to -

    SelectionStart="{Binding Rules.Min, Mode=TwoWay}"
    SelectionEnd="{Binding Rules.Max, Mode=TwoWay}"
    TickFrequency="5"
    IsSnapToTickEnabled="True"
    IsSelectionRangeEnabled="True"

    My issue is when I change the SelectionEnd from 20 to 50 and then "cancel" that value setting it back to 20 in the codebehind the next time I move the end thumb it jumps back up to 50 when I would expect it to go to 25.  I have a sample project I can attach but don't see a place for it.  I am using version 2011.2.1010.1040 of Telerik.Windows.Controls.

    Reply

  • Petar Mladenov Petar Mladenov admin's avatar

    Posted on Nov 14, 2011 (permalink)

    Hello Derek,

     Could you please try to use the Selection property (of type SelectionRange<double>) of the the RadSlider, instead of SelectionStart and SelectionEnd ? We recently fixed some issues when binding the SelectionStart and SelectionEnd, but we highly suggest you to use the Selection property instead. With the upcoming Q3 Release , we will introduce these fixes among with documentation describing how to bind and use the Selection successfully.

    Best wishes,
    Petar Mladenov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

    Reply

  • Derek avatar

    Posted on Nov 15, 2011 (permalink)

    Hey Petar,

    I tried binding to the Selection and it still behaves the same. I have supplied the code for my sample project so you can see what I am trying to do.

    <Grid x:Name="LayoutRoot" Background="White">
            <StackPanel x:Name="Panel" x:FieldModifier="public">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="100"/>
                        <ColumnDefinition Width="300" />
                    </Grid.ColumnDefinitions>
     
                    <Grid.RowDefinitions>
                        <RowDefinition Height="50"/>
                    </Grid.RowDefinitions>
                    <Button Content="Copy Old Value" Click="Button_Click" Grid.Column="0"/>
                    <telerik:RadSlider x:Name="Slider"
                                x:FieldModifier="public"
                                TickPlacement="BottomRight"
                                VerticalAlignment="Bottom"
                                SelectionStart="0"
                                Selection="{Binding Rules.Selection, Mode=TwoWay}"
                                TickFrequency="5"
                                IsSnapToTickEnabled="True"
                                IsSelectionRangeEnabled="True"
                                Minimum="0" Maximum="50"
                                Margin="10,0,10,0"
                                   Grid.Column="2">
                        <telerik:RadSlider.TickTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="{Binding}" FontSize="10" />
                                </StackPanel>
                            </DataTemplate>
                        </telerik:RadSlider.TickTemplate>
                    </telerik:RadSlider>
                </Grid>
            </StackPanel>
        </Grid>

    public partial class MainPage : UserControl, INotifyPropertyChanged
        {
            private Weight weightVO = new Weight();
            public Weight WeightVO
            {
                get { return weightVO; }
                set { weightVO = value; }
            }
     
            public MainPage()
            {
                InitializeComponent();
                Panel.DataContext = WeightVO.Temp;
            }
     
            private void Button_Click(object sender, RoutedEventArgs e)
            {
                WeightVO.SetTempToCurrent();
            }
     
            public event PropertyChangedEventHandler PropertyChanged;
            protected void OnPropertyChanged(string name)
            {
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs(name));
                }
            }
        }

    public class Weight
        {
            private Search current = DefaultSearch();
            public Search Current
            {
                get { return current; }
                set { current = value; }
            }
     
            private Search temp = DefaultSearch();
            public Search Temp
            {
                get { return temp; }
                set { temp = value; }
            }
     
            public void SetTempToCurrent()
            {
                Temp.CopyValues(Current);
            }
     
            public static Search DefaultSearch()
            {
                Rules rules = new Rules() {End = 5d, Selection = new SelectionRange<double>(0, 5)};
                return new Search() { Rules = rules };
            }
        }

    public class Search : INotifyPropertyChanged
        {
            private Rules rules = new Rules();
            public Rules Rules
            {
                get { return rules; }
                set
                {
                    rules = value;
                    OnPropertyChanged("Rules");
                }
            }
     
            public void CopyValues(Search search)
            {
                Rules = new Rules(search.Rules);
            }
     
            public event PropertyChangedEventHandler PropertyChanged;
            protected void OnPropertyChanged(string name)
            {
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs(name));
                }
            }
        }


    public class Rules : INotifyPropertyChanged
        {
            private double end;
            public double End
            {
                get { return end; }
                set
                {
                    end = value;
                    OnPropertyChanged("End");
                }
            }
     
            private SelectionRange<double> selection = new SelectionRange<double>(0, 5);
            public SelectionRange<double> Selection
            {
                get { return selection; }
                set
                {
                    selection = value;
                    End = selection.End;
                    OnPropertyChanged("Selection");
                }
            }
     
     
            public Rules() { }
     
            public Rules(Rules rules)
            {
                end = rules.end;
                     selection = rules.selection;
            }
     
            public event PropertyChangedEventHandler PropertyChanged;
            protected void OnPropertyChanged(string name)
            {
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs(name));
                }
            }
        }

    Reply

  • Alex Fidanov Alex Fidanov admin's avatar

    Posted on Nov 18, 2011 (permalink)

    Hello Derek,

    Thank you for providing the code snippet. We have managed to create a sample application based on the code snippets. Is it possible to send us some steps to reproduce the issue using this code and what is the expected result. Thank you.

    All the best,
    Alex Fidanov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

    Reply

  • Derek avatar

    Posted on Nov 18, 2011 (permalink)

    Hi Alex,

    Steps to reproduce:
    Move end slider from 5 to 30
    Click Copy Old Value Button - should cause end slider to move back to 5
    Move end slider again

    Actual Results
    End slider jumps  back to 30

    Expected 
    End slider jumps to 10

    Reply

  • Alex Fidanov Alex Fidanov admin's avatar

    Posted on Nov 21, 2011 (permalink)

    Hello Derek,

    Thank you for reporting this. We have acknowledged this as an issue in the slider control. I have logged this in our PITS unde "Incorrect range after changing the value and dragging a thumb" and you will be able to track it in the system within one day. I have also updated your Telerik points.

    All the best,
    Alex Fidanov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > Slider > Selection start/end jump when changing binding value in codebehind
Related resources for "Selection start/end jump when changing binding value in codebehind"

Silverlight Slider Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]