Slider - Increase Decrease Events

5 posts, 1 answers
  1. Bradley Lane
    Bradley Lane avatar
    22 posts
    Member since:
    Aug 2012

    Posted 07 Feb 2010 Link to this post

    Hi,

    I'm trying to find an event for when the increase and decrease buttons (on the sides of the slider) are pressed. I would use the Value Changed Event except it fires too often for my specific purpose. Drag Completed works nicely for the actual slider, just need more control over the buttons.

    Thanks,
    Brad
  2. Answer
    Tihomir Petkov
    Admin
    Tihomir Petkov avatar
    576 posts

    Posted 10 Feb 2010 Link to this post

    Hello Bradley,

    Since it's a Routedevent, you can subscribe to the Click event of the two repeat buttons like this:

    mySlider.AddHandler(RepeatButton.ClickEvent, new RoutedEventHandler(slider_Click), true);

    The above line will call the r_Click method when the increase/decrease buttons are clicked. Let me know if this works for you.

    All the best,
    Tihomir Petkov
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Kevin
    Kevin avatar
    10 posts
    Member since:
    Jul 2012

    Posted 08 Aug 2012 Link to this post

    Can you show me how to do this (subscribe to these routed events) in XAML? I'm using a RadSlider in an MVVM application with Value bound, but I also need to get the handle click events so I can run some code before the binding fires. These events do fire before the Value binding is executed right?

    I would also want to identify a thumb drag in the same way, for the same purpose.

    I've tried the following but this did not work...meaning that my IncreaseHandleClick event was never hit.

                    <telerik:RadSlider Name="ZP" Height="Auto" Width="100" HandlesVisibility="Visible" VerticalAlignment="Center" Margin="3"
                                       Minimum="25" Maximum="1600" SmallChange="25" IsMoveToPointEnabled="True" 
                                        IsDeferredDraggingEnabled="True" Value="{Binding ZoomPercent}">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="IncreaseHandleClick">
                                <cal:ActionMessage MethodName="IncreaseHandleClick"/>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </telerik:RadSlider>

    Thanks!
  5. Kevin
    Kevin avatar
    10 posts
    Member since:
    Jul 2012

    Posted 08 Aug 2012 Link to this post

    Can you show me how to do this (subscribe to these routed events) in XAML? I'm using a RadSlider in an MVVM application with Value bound, but I also need to get the handle click events so I can run some code before the binding fires. These events do fire before the Value binding is executed right?

    I would also want to identify a thumb drag in the same way, for the same purpose.

    I've tried the following but this did not work...meaning that my IncreaseHandleClick event was never hit.

                    <telerik:RadSlider Name="ZP" Height="Auto" Width="100" HandlesVisibility="Visible" VerticalAlignment="Center" Margin="3"
                                       Minimum="25" Maximum="1600" SmallChange="25" IsMoveToPointEnabled="True" 
                                        IsDeferredDraggingEnabled="True" Value="{Binding ZoomPercent}">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="IncreaseHandleClick">
                                <cal:ActionMessage MethodName="IncreaseHandleClick"/>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </telerik:RadSlider>

    Thanks!
  6. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 13 Aug 2012 Link to this post

    Hello Kevin,

     Currently there is no such public event like Increase/DecreaseHandleClick. You have to find the RepeatButtons from the Template and subscribe for their Click events in code behind;

    private void RadSlider_Loaded(object sender, RoutedEventArgs e)
            {
                var repatButtons = (sender as RadSlider).ChildrenOfType<RepeatButton>();
                if (repatButtons != null)
                {
                    foreach (var button in repatButtons)
                    {
                        button.Click += HanldeButtonClick;
                    }
                }
            }
     
            private void HanldeButtonClick(object sender, RoutedEventArgs e)
            {
                 
            }
    For the Thumb Drag you can use DragStartedEvent:
    <telerik:RadSlider  DragStarted="slider_DragStarted" HandlesVisibility="Visible" Loaded="RadSlider_Loaded"    ValueChanged="RadSlider_ValueChanged"                    
                          />
    private void slider_DragStarted(object sender, RadDragStartedEventArgs e)
        {
     
        }
    Kind regards,
    Petar Mladenov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
UI for WPF is Visual Studio 2017 Ready