Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

UIElement.IsMouseOver Property

Gets a value indicating whether the mouse pointer is located over this element (including child elements in the visual tree). This is a dependency property.

Namespace: System.Windows
Assembly: PresentationCore (in presentationcore.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public bool IsMouseOver { get; }
/** @property */
public final boolean get_IsMouseOver ()

public final function get IsMouseOver () : boolean

You cannot use this property in XAML.

Property Value

true if mouse pointer is over the element or its child elements; otherwise, false. The default is false.

Identifier field

IsMouseOverProperty

Metadata properties set to true

None

Typically, controls are composited such that the various elements inside the control (the visual tree) will all report the mouse state for the containing control. For example, a ListBox style control will report IsMouseOver as true if the mouse is anywhere over its geometry, including any ListBoxItem.

Although an analogous "IsMouseOverChanged" event does not exist, several similar events do. For example, you can handle MouseEnter, MouseMove, and IsMouseDirectlyOverChanged.

If this element capures the mouse, this property remains true until mouse capture is lost and the mouse pointer leaves the element bounds.

Some controls deliberately capture the mouse on certain actions that do not appear to directly involve the mouse. This can lead to IsMouseOver being true even though the mouse has not apparently moved.

The following example references this property as the property type of a Trigger. If the mouse is over the button, the style applies a green background to it.

<Style x:Key="Triggers" TargetType="Button">
    <Style.Triggers>
    <Trigger Property="IsMouseOver" Value="true">
        <Setter Property = "Background" Value="Red"/>
    </Trigger>
    <Trigger Property="IsPressed" Value="true">
        <Setter Property = "Foreground" Value="Green"/>
    </Trigger>
    </Style.Triggers>
</Style>

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft