0

I'm trying to get WPF Slider value after the user finishing to drag the thumb or clicking to move to specific point.

i want to save the new value in db by listening to some kind of event. how can i do this?

i tried the solutions on this question but i end up with nothing - WPF: Slider with an event that triggers after a user drags

each time it enters the event lots of times

thanks.

xaml:

<Slider Value="{Binding VoipVolume}" MouseLeftButtonUp="slider_MouseLeftButtonUp"/>

codebehind:

public double VoipVolume
    {
        get { return (double)GetValue(VoipVolumeProperty); }
        set
        {
            SetValue(VoipVolumeProperty, value);
            VolumeChanged(value);
        }
    }

private void VolumeChanged(object value)
    {
        StationViewModel viewModel = this.DataContext as StationViewModel;

        if (viewModel != null)
        {
            if (end)
            {
                viewModel.OnVolumeChange((float)VoipVolume);
                end = false;
            }
        }
    }
    bool end = false;


    private void slider_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
    {
        end = true;
    }

3 Answers3

0

Possibly duplicate. hope this may help you out: stackoverflow.com/a/723547/1611490

 <Slider Thumb.DragCompleted="MySlider_DragCompleted" />

and under MySlider_DragCompleted event, update your property of the VM or get the value.

Ishan Pandya
  • 81
  • 2
  • 10
0

if your are using FW 4.5 or above, try using the "Dalay" property.

http://www.jonathanantoine.com/2011/09/21/wpf-4-5-part-4-the-new-bindings-delay-property/

Ishan Pandya
  • 81
  • 2
  • 10
0

We didn't have a choice, in the end we use TickFrequency because we need to save the changes in the slider to db, and we don't want it to happen for every 0.001..

thanks anyway..