Slider provides incorrect values

6 posts, 0 answers
  1. Jason
    Jason avatar
    5 posts
    Member since:
    Jul 2009

    Posted 31 May 2011 Link to this post

    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>
  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 01 Jun 2011 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Jason
    Jason avatar
    5 posts
    Member since:
    Jul 2009

    Posted 01 Jun 2011 Link to this post

    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);
            }
  5. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 03 Jun 2011 Link to this post

    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
  6. Jason
    Jason avatar
    5 posts
    Member since:
    Jul 2009

    Posted 06 Jun 2011 Link to this post

    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
  7. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 07 Jun 2011 Link to this post

    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
Back to Top
UI for WPF is Visual Studio 2017 Ready