private bool ApplyVelocity() { if (IsDragging || _velocity.Value == 0) { return(false); } Dispatcher.BeginInvoke(new Action(() => HomeScrollViewer.ScrollToVerticalOffset(HomeScrollViewer.VerticalOffset - _velocity.Value))); var size = Math.Abs(_velocity.Value); var sign = size / _velocity.Value; _velocity.Value = sign * Math.Max(0, Math.Min(size * 0.95, size - 1)); return(true); }
private void OnAddGoalClicked(object sender, RoutedEventArgs e) { string title = "Neues Ziel"; int i = 1; while (Goals.Exists(x => x.Title == title)) { title = title.Split(' ')[0] + " " + title.Split(' ')[1] + " " + (++i); } Goal goal = new Goal(title); GoalControl goalControl = new GoalControl(this, goal); HomeStackpanel.Children.Add(goalControl); Goals.Add(goal); goalControl.NameLabel.BeginEditing(); HomeScrollViewer.ScrollToBottom(); }
private void HomeScrollViewer_OnPreviewMouseMove(object sender, MouseEventArgs e) { if (!IsDragging) { return; } var pos = e.GetPosition(this); var y = pos.Y - _mousePosition.Y; if (y == 0) { return; } _velocity.TryUpdate(y); HomeScrollViewer.ScrollToVerticalOffset(HomeScrollViewer.VerticalOffset - y); _mousePosition = pos; }