Open.Core.MouseExtensions.IsMouseWithin C# (CSharp) Method

IsMouseWithin() public static method

Determines whether the mouse is currently within the bounds of the given element.
public static IsMouseWithin ( this e, FrameworkElement element ) : bool
e this The event args returned from a mouse event (eg. MouseLeftButtonUp)
element System.Windows.FrameworkElement 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;
        }
    }
MouseExtensions