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

Slider - Increase Decrease Events

4 Answers 495 Views
Slider
This is a migrated thread and some comments may be shown as answers.
Bradley Lane
Top achievements
Rank 1
Bradley Lane asked on 08 Feb 2010, 05:04 AM
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

4 Answers, 1 is accepted

Sort by
0
Accepted
Tihomir Petkov
Telerik team
answered on 10 Feb 2010, 02:55 PM
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.
0
Kevin
Top achievements
Rank 1
answered on 08 Aug 2012, 10:46 PM
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!
0
Kevin
Top achievements
Rank 1
answered on 08 Aug 2012, 10:46 PM
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!
0
Petar Mladenov
Telerik team
answered on 13 Aug 2012, 01:50 PM
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.

Tags
Slider
Asked by
Bradley Lane
Top achievements
Rank 1
Answers by
Tihomir Petkov
Telerik team
Kevin
Top achievements
Rank 1
Petar Mladenov
Telerik team
Share this question
or