0

我正在尝试使用 Behavior 来抓住钥匙

public class mONITORKeyDown : Behavior<UserControl>
    {

        public static readonly DependencyProperty _ShortCuts =
                    DependencyProperty.Register(
                        "ShortCuts",
                        typeof(Dictionary<Tuple<ModifierKeys, Key>, ICommand>),
                        typeof(BillingMangerKeyDown),
                        new PropertyMetadata( null));


        protected override void OnAttached()
        {
          // ShortCuts = new Dictionary<Tuple<ModifierKeys, Key>, ICommand>();
            AssociatedObject.KeyDown += _KeyBoardBehaviorKeyDown;
        }

        protected override void OnDetaching()
        {

            AssociatedObject.KeyDown -= _KeyBoardBehaviorKeyDown;
        }



        void _KeyBoardBehaviorKeyDown(object sender, KeyEventArgs e)
        {
            if(Keyboard.Modifiers == KeyModifiers.Control && e.Key==Key.Down)

        }
        }

问题是,一旦我单击 cntrl,它就会触发事件,然后单击 enter + 向下箭头没有任何作用

4

1 回答 1

1

我认为它应该可以帮助你!

  private void InvoiceGrid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
    {

        if (Keyboard.Modifiers == ModifierKeys.Control)
        {
            ((ResolutionVM)this.DataContext).PrepareListForMassUpdate();
        }
        else
        {
            ((ResolutionVM)this.DataContext).ClearListForMassUpdate();
        }

    }
于 2013-01-09T09:21:33.680 回答