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
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
0
Accepted
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.
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!
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!
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
Hello Kevin,
For the Thumb Drag you can use DragStartedEvent:
Kind regards,
Petar Mladenov
the Telerik team
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)
{
}
<
telerik:RadSlider
DragStarted
=
"slider_DragStarted"
HandlesVisibility
=
"Visible"
Loaded
=
"RadSlider_Loaded"
ValueChanged
=
"RadSlider_ValueChanged"
/>
private
void
slider_DragStarted(
object
sender, RadDragStartedEventArgs e)
{
}
Petar Mladenov
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.