Ability to lock handle?

9 posts, 1 answers
  1. Nicole
    Nicole avatar
    30 posts
    Member since:
    Mar 2011

    Posted 14 Feb 2012 Link to this post

    I am using a RadSlider to set the date range for a separate chart as follows:

    <telerik:RadSlider x:Name="sldTimeSelection" Grid.Row="1" Grid.Column="0" Orientation="Horizontal"  
                       Minimum="-365" Maximum="0" IsMoveToPointEnabled="True"
                       IsSelectionRangeEnabled="True" MinimumRangeSpan="7" MaximumRangeSpan="365" 
                       SelectionStart="-30" SelectionEnd="0"
                       IsSnapToTickEnabled="True" TickPlacement="BottomRight" Ticks="-7, -30, -90, -180, -365" 
                                                        EnableSideTicks="False" Margin="5,0" >
    </telerik:RadSlider>


    Is there any way to lock the Increase Handle into it's position at 0?  We do not, at this time, wish to enable the customer to look at a range of historical data, but the customer likes the look of the rage versus the look of a single thumb selection.

    I could ignore the increase handle value and reset it back to 0 in the event handler, but I don't think this would be user friendly and might cause frustration.
  2. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 16 Feb 2012 Link to this post

    Hi Nicole,

     Try setting the AlternateThumbStyle with an IsEnabled setter:

    <telerik:RadSlider>
        <telerik:RadSlider.AlternateThumbStyle>
            <Style TargetType="Thumb">
                <Setter Property="IsEnabled" Value="False" />
            </Style>
        </telerik:RadSlider.AlternateThumbStyle>
    </telerik:RadSlider>

    Give it a try and let me know if this works for you.

    Greetings,
    Kiril Stanoev
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. DevCraft banner
  4. Nicole
    Nicole avatar
    30 posts
    Member since:
    Mar 2011

    Posted 16 Feb 2012 Link to this post

    Thanks for the idea, Kiril.  I get an error that "the attachable property 'AlternateThumbStyle' was not found in type RadSlider'

    It looks like this was added in 2011.3, but we are on 2011.2.290.1040 and I am not allowed to upgrade versions.  Are you aware of a work-around for 2011.2?

  5. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 16 Feb 2012 Link to this post

    Hi Nicole,

    In this case you will have to traverse the visual tree of RadSlider and find the desired thumb.

    <telerik:RadSlider x:Name="slider1" Loaded="slider1_Loaded" IsSelectionRangeEnabled="True" />

    private void slider1_Loaded(object sender, RoutedEventArgs e)
    {
        this.Dispatcher.BeginInvoke(() =>
        {
            var selectionStartThumb = this.slider1.ChildrenOfType<Thumb>().Where(thumb => thumb.Name == "RangeStartThumb").FirstOrDefault();
            if (selectionStartThumb != null)
            {
                selectionStartThumb.IsEnabled = false;
            }
        });
    }

    Give it a try and let me know if it works. I'd be glad to further assist you.

    Regards,
    Kiril Stanoev
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  6. Nicole
    Nicole avatar
    30 posts
    Member since:
    Mar 2011

    Posted 16 Feb 2012 Link to this post

    I modified this a bit to get rid of a "not a delegate type" error as follows:

    this.Dispatcher.BeginInvoke((Action)(() =>
    {
        var selectionStartThumb = this.sldTimeSelection.ChildrenOfType<Thumb>().Where(thumb => thumb.Name == "RangeStartThumb").FirstOrDefault();
        if (selectionStartThumb != null)
        {
            selectionStartThumb.IsEnabled = false;
        }
    }));

    However, I am still getting an error that "The type or namespace name 'Thumb' could not be found."  The project and .cs both reference Teleriks.Windows.Controls. 

    Do I need another reference, or is the type maybe incorrect?  I don't see anything in intellisense that looks close.
  7. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 17 Feb 2012 Link to this post

    Hi Nicole,

     I am not sure what might be causing this issue, but it smells like it has something to do with namespaces. However I need more information because I am not sure what might be causing the issue.

    Kind regards,
    Kiril Stanoev
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  8. Nicole
    Nicole avatar
    30 posts
    Member since:
    Mar 2011

    Posted 21 Feb 2012 Link to this post

    Hi Kiril,

    What kind of information would help?  Here's my using section:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    using System.IO.IsolatedStorage;
    using Dashboard.Silverlight.SystemDetailsService;
    using Telerik.Windows.Controls;
    using Dashboard.Silverlight.SupportClasses;
    using System.Windows.Browser;
    using Telerik.Windows.Controls.GridView;
    using Dashboard.Silverlight.Views.Aviation;
    using Telerik.Windows.Controls.Charting;

  9. Answer
    Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 23 Feb 2012 Link to this post

    Hello Nicole,

    Could you please try the following approach and let me know if it helps.

    this.Dispatcher.BeginInvoke((Action)(() =>
    {
        var selectionStartThumb = this.sldTimeSelection.ChildrenOfType<System.Windows.Controls.Primitives.Thumb>().Where(thumb => thumb.Name == "RangeStartThumb").FirstOrDefault();
        if (selectionStartThumb != null)
        {
            selectionStartThumb.IsEnabled = false;
        }
    }));
     

    Regards,
    Kiril Stanoev
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  10. Nicole
    Nicole avatar
    30 posts
    Member since:
    Mar 2011

    Posted 23 Feb 2012 Link to this post

    Thanks, that works great.  It locked down the wrong thumb but I changed that easily.

    this.Dispatcher.BeginInvoke((Action)(() =>
    {
        var selectionEndThumb = this.sldTimeSelection.ChildrenOfType<System.Windows.Controls.Primitives.Thumb>().Where(thumb => thumb.Name == "RangeEndThumb").FirstOrDefault();
        if (selectionEndThumb != null)
        {
            selectionEndThumb.IsEnabled = false;
        }
    }));
Back to Top
DevCraft banner