-1

I want to handle a buttons MouseEnter event only for mouse actions. So I have to detect if MouseEnter is triggered by mouse or by keyboard.

private void button_onMouseEnter(object sender, MouseEventArgs e)
{
    Button button = (Button)sender;

    if (!button.IsMouseOver)            return; // not working
    if (!button.IsMouseDirectlyOver)    return; // not working
    ...
}
Pollitzer
  • 1,580
  • 3
  • 18
  • 28

1 Answers1

1

you can check most recent input device

if (InputManager.Current.MostRecentInputDevice is KeyboardDevice);

as been discussed here:

How to tell if a button click event was triggered by keyboard or mouse in WPF?

Community
  • 1
  • 1
Spirosi
  • 324
  • 1
  • 15