protected override void OnPreviewMouseMove(MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed && !_isDragging) { CommandButton selectedItem = this.SelectedItem as CommandButton; if (selectedItem == null) { return; } IDragableCommandModel cmd = selectedItem.CommandModel as IDragableCommandModel; if (cmd == null) { return; } Point position = e.GetPosition(null); if (Math.Abs(position.X - _startPoint.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(position.Y - _startPoint.Y) > SystemParameters.MinimumVerticalDragDistance) { DoDragDrop(e, cmd); this.SelectedIndex = -1; } } }
private static void OnCommandModelPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { CommandButton commandButton = (CommandButton)obj; if (args.NewValue != null) { CommandModel commandModel = (CommandModel)args.NewValue; commandButton.Command = commandModel.Command; commandButton.Content = commandModel.Name; commandButton.ToolTip = commandModel.Description; commandButton.Image = commandModel.Image; } else { commandButton.Content = null; commandButton.Image = null; } }