void ProgressSliderElement_ScrubbingStarted(object sender, ValueRoutedEventArgs e) { if (ViewModel != null) { var vm = ViewModel; // hold onto this in case the ViewModel changes because of this action. This way we can ensure we're calling the same one. bool canceled = false; vm.StartScrub(TimeSpan.FromSeconds(e.Value), out canceled); if (canceled) { ProgressSliderElement.CancelScrub(); vm.CompleteScrub(TimeSpan.FromSeconds(e.Value), ref canceled); } e.Canceled = canceled; } }
private void InitializeProgressSlider() { if (ProgressSliderElement != null) { UnwireProgressSliderEvents(); if (ViewModel != null) { ProgressSliderElement.SetBinding(SeekableSlider.IsEnabledProperty, new Binding() { Path = new PropertyPath("IsScrubbingEnabled"), Source = ViewModel }); ProgressSliderElement.SetBinding(SeekableSlider.ActualValueProperty, new Binding() { Path = new PropertyPath("Position.TotalSeconds"), Source = ViewModel }); ProgressSliderElement.SetBinding(SeekableSlider.MinimumProperty, new Binding() { Path = new PropertyPath("StartTime.TotalSeconds"), Source = ViewModel }); ProgressSliderElement.SetBinding(SeekableSlider.MaximumProperty, new Binding() { Path = new PropertyPath("EndTime.TotalSeconds"), Source = ViewModel }); ProgressSliderElement.SetBinding(SeekableSlider.MaxValueProperty, new Binding() { Path = new PropertyPath("MaxPosition.TotalSeconds"), Source = ViewModel }); } else { ProgressSliderElement.ClearValue(SeekableSlider.IsEnabledProperty); ProgressSliderElement.ClearValue(SeekableSlider.ActualValueProperty); ProgressSliderElement.ClearValue(SeekableSlider.MinimumProperty); ProgressSliderElement.ClearValue(SeekableSlider.MaximumProperty); ProgressSliderElement.ClearValue(SeekableSlider.MaxValueProperty); } WireProgressSliderEvents(); } }