In WPF most controls have MouseUp and MouseDown events (and the mouse-button-specific variations) but not a simple Click event that ca
Here is a simple solution that I use on a fairly regular basis. It is easy, and works in all sorts of scenarios.
In your code, place this.
private object DownOn = null;
private void LeftButtonUp(object sender, MouseButtonEventArgs e)
{
if (DownOn == sender)
{
MessageBox.Show((sender as FrameworkElement).Name);
}
DownOn = null;
}
private void LeftButtonDown(object sender, MouseButtonEventArgs e)
{
DownOn = sender;
}
Now all you have to do is setup handlers for all of the controls that you care about i.e.
If you have a ton of controls, and don't want to do it all in XAML, you can do it in your controls / window constructor programatically.
This will cover most of your scenarios, and it can easily be tweaked to handle special cases.