tags:

views:

72

answers:

3

How can I detect that the button in my application is still clicked (down)? and how to know when it is released?

+3  A: 

Try using the MouseDown and MouseUp events

Example:

XAML:

<Button x:Name="Button1" MouseDown="OnMouseDown" Content="Button1" />

Code behind:

private void OnMouseDown(object sender, MouseButtonEventArgs e)
{
    //do something
}

Same goes for MouseUp

Darko Z
@Darko Z: any example?
sikas
theres also more information in the links
Darko Z
A: 

You need to handle the MouseDown and MouseUp events.

SLaks
@SLaKs: any example?
sikas
+4  A: 

Are you looking for RepeatButton? It's one of the built-in WPF button controls, and it raises its Click event repeatedly if you press and hold the button. It's used internally to implement things like the "up-arrow" and "down-arrow" buttons on a scrollbar.

Joe White
this is what I was exactly looking for
sikas
@Joe White: +1 for reading OP's mind:)
Veer