This is a migrated thread and some comments may be shown as answers.

Slider provides incorrect values

5 Answers 126 Views
Slider
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 31 May 2011, 01:18 PM
Steps to reproduce:

1) Subclass RadSlider as pasted in the code below, and put that control in a window as illustrated below.
2) Set a trace point in "OnSelectionRangeChanged" and output newValue.SelectionStart
3) Once the app is loaded expand the range selection so you can click and drag the selection
4) Click and drag the selection from right to left and observer SelectionStart, the value is not consistently 0.0 when you drag the selection to the beginning of the range unless you change the range itself (expand it). 

Code:

Subclassed RadSlider

public class JSlider : RadSlider
    {
        public JSlider()
        {
            IsSelectionRangeEnabled = true;
        }
 
        /// <summary>
        /// Raises the <see cref="E:System.Windows.FrameworkElement.SizeChanged"/> event, using the specified information as part of the eventual event data.
        /// </summary>
        /// <param name="sizeInfo">Details of the old and new size involved in the change.</param>
        protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
        {
            base.OnRenderSizeChanged(sizeInfo);
 
            // setup the slider with the correct maximum based on our current available width
            Minimum = 0;
            Maximum = ActualWidth;
        }
 
 
        protected override void OnSelectionRangeChanged(SelectionRangeChangedEventArgs oldValue, SelectionRangeChangedEventArgs newValue)
        {
            base.OnSelectionRangeChanged(oldValue, newValue);
 
 
        }
    }

XAML

<Grid>
        <DockPanel>
            <WpfApplication15:JSlider DockPanel.Dock="Bottom" Height="200"/>
        </DockPanel>
    </Grid>

5 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 01 Jun 2011, 12:37 PM
Hi Jason Clark,

I prepared a sample that uses your code and I cannot detect strange behavior. You can see that SelectionEnd and SelectionStart start from 0.4 and 0.6 ( which is expected) and then change properly ( from 0 to the maximum width (the "Maximum" that you set in code behind)). Please examine the solution and let me know if I have missed something.
 You should also keep in mind that we have re-factored RadSlider recently and the new version will be available with the upcoming Q2 2011 Beta (mid -June). Furthermore, inheriting a RadControl is a custom operation that is out of our support scope operation. So you can also try to isolate your issue in a RadSlider, not its inheritant and let us know if the problem is still reproducible.
Thank you in advance for your cooperation.

Kind regards,
Petar Mladenov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jason
Top achievements
Rank 1
answered on 01 Jun 2011, 03:57 PM
So... yes when you bind to SelectionStart it works, however if you override your SelectionRangeChanged event and simply put the code below you will see in the output window that the SelectionStart, SelectionEnd values are NOT the same as the ones that you bound to in your sample.  Somehow your event is not catching the last value of SelectionStart properly.  This is most definitely a bug in your RadSlider control, as i haven't done anything in the override :)  If you supply a method that can be overridden then you should indeed support that the event values that it receives are actually correct :).

protected override void OnSelectionRangeChanged(SelectionRangeChangedEventArgs oldValue, SelectionRangeChangedEventArgs newValue)
        {
            base.OnSelectionRangeChanged(oldValue, newValue);
  
            Debug.WriteLine("SEL RANGE " + newValue.SelectionStart + " - " + newValue.SelectionEnd);
        }
0
Tina Stancheva
Telerik team
answered on 03 Jun 2011, 12:32 PM
Hello Jason Clark,

We are still unable to reproduce the issue on our side. This is a video illustrating the behavior on our side. Can you please have a look at it and let me know if I am missing something.

Also, as Peter mentioned, with the upcoming Beta release an improved implementation of the RadSlider will be released, which will enhance the controls performance. So you will be soon able to give it a try and see if it will better fit your needs.

Best wishes,
Tina Stancheva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jason
Top achievements
Rank 1
answered on 06 Jun 2011, 04:51 PM
Ok, watched the video here is what you didn't do which is how the problem raises itself...

Grab the entire range and move it don't expand the start or end click the range and drag it left and right ensure you drag it all the way to the left each time and you should see that you get different values for SelectionStart
0
Petar Mladenov
Telerik team
answered on 07 Jun 2011, 02:50 PM
Hi Jason Clark,

Thank you for your video and explanations in the other thread. Indeed, the bound value of SelectionStart works correctly as an opposition of the value that come from the SelectionRangeChanged event handler.
Actually this event is marked as "obsolete" in the new RadSlider version which will be released with the Q2 2011 Beta (mid -June). However, you will be able to use the new SelectionChanged event in the same way. We updated your telerik account points as a thanks for your cooperation. Thank you again and please stay tuned for the Beta.

Greetings,
Petar Mladenov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Slider
Asked by
Jason
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Jason
Top achievements
Rank 1
Tina Stancheva
Telerik team
Share this question
or