My question is simple. Is it possible to trigger mouseup and mousedown on keyup and keydown event respectivey in WPF.
I have set of event handlers for mouse down and mouse up in my custom control. I want to trigger the same if the user try to press the spacebar on my custom button.
private void CustomButton_MouseDown(object sender, MouseButtonEventArgs e)
{
eventlabel.Content = "Mousedown event Triggered";
}
private void CustomButton_MouseUp(object sender, MouseButtonEventArgs e)
{
eventlabel.Content = "MouseUp event Triggered";
}
private void CustomButton_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Space)
{
//Need to trigger all the handlers of mousedown
}
}
private void CustomButton_KeyUp(object sender, KeyEventArgs e)
{
if (e.Key == Key.Space)
{
//Need to trigger all the handlers of mouseup
}
}