I have sliders with twoway binding enabled at startup. But when I move them, moving is not smooth enought. So, I decide to change binding mode from twoway to onewaytosource after Thumbs.DragStarted event is called, but this lead to immediate changing value
from 1 to 0.
My question is: How to prevent slider from changing its value during new binding if I set OneWayToSource mode?
My code behind is below.
private void SliderCameraZ_OnDragStarted(object sender, DragStartedEventArgs e) { try { BindingExpression bindingExpression = ((Slider) sender).GetBindingExpression(Slider.ValueProperty); BindingOperations.ClearBinding((Slider) sender, Slider.ValueProperty); Binding binding = new Binding(); binding.Path = bindingExpression.ParentBinding.Path; binding.Mode = BindingMode.OneWayToSource; binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; ((Slider)sender).SetBinding(Slider.ValueProperty, binding); } catch (Exception exception) { MessageBox.Show(exception.Message + exception.StackTrace + exception.TargetSite); } }