我正在尝试使用行为来抓住关键
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,它就会触发事件,点击后输入+向下箭头无效工作
答案 0 :(得分:1)
我认为它可以帮助你!!!
private void InvoiceGrid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
if (Keyboard.Modifiers == ModifierKeys.Control)
{
((ResolutionVM)this.DataContext).PrepareListForMassUpdate();
}
else
{
((ResolutionVM)this.DataContext).ClearListForMassUpdate();
}
}