Ono
Ono

Reputation: 1357

WPF range slider move by click

Thanks for reading my thread

I have a range slider, which I want to move, perhaps 3% of the total range, each time I click the track. Here is the xaml code:

<RSlider:FormattedSlider x:Name="powerSlider"
                                               Value="{Binding Path=PowerPosition, Mode=TwoWay, UpdateSourceTrigger=Explicit}"
                                               Minimum="{Binding Path=PowerMin, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
                                               Maximum="{Binding Path=PowerMax, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
                                               TickPlacement="None"
                                               AutoToolTipPlacement="BottomRight"
                                               Margin="1"
                                               Orientation="Vertical"
                                               Height="150"
                                               Width="50"
                                               ToolTip="Adjust laser power"
                                               HorizontalAlignment="Left"
                                               MouseWheel="PowerSlider_MouseWheel"
                                               TickFrequency="1"
                                               Thumb.DragCompleted="powerSlider_DragCompleted"
                                               Thumb.DragStarted="powerSlider_DragStarted" >                                             
                        <RSlider:FormattedSlider.RenderTransform>
                            <ScaleTransform ScaleX="3.0"
                                            ScaleY="1.0" />
                        </RSlider:FormattedSlider.RenderTransform>
                    </RSlider:FormattedSlider>

I am trying to add in xaml with:

Track.OnMouseLeftButtonDown =" powerSlider_Clicked"

but it does not recognize Track.OnMouseLeftButtonDown as a property.

With current xaml, the problem is that if I left-click on the track up, the thumb will raise but it will quickly drops to the bottom, and then it just repeating itself with that.

I am wondering how I can fill in the C# code to make it work? Thanks a lot.

Upvotes: 1

Views: 1717

Answers (1)

sondergard
sondergard

Reputation: 3234

If it is a standard WPF slider, there is a property called LargeChange which controls the amount the slider should move when clicking the Track part.

Upvotes: 2

Related Questions