public static IsMouseWithin ( this e, |
||
e | this | The event args returned from a mouse event (eg. MouseLeftButtonUp) |
element | The element to examine. | |
return | bool |
public static bool IsMouseWithin(this MouseButtonEventArgs e, FrameworkElement element)
{
// Setup initial conditions.
if (e == null) return false;
if (element == null) return false;
var position = e.GetPosition(element);
// Check bounds.
if (position.X < 0 || position.Y < 0) return false;
return position.X <= element.ActualWidth && position.Y <= element.ActualHeight;
}
}