UIElement.IsMouseOver Property
Assembly: PresentationCore (in presentationcore.dll)
XML Namespace: http://schemas.microsoft.com/winfx/2006/xaml/presentation
'Declaration Public ReadOnly Property IsMouseOver As Boolean 'Usage Dim instance As UIElement Dim value As Boolean value = instance.IsMouseOver
/** @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.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.