ContentElement.IsMouseOver Property


取得值,這個值表示滑鼠指標是否位於這個項目上方 (包括視覺子項目或其複合控制項)。Gets a value that indicates whether the mouse pointer is located over this element (including visual child elements, or its control compositing).

 property bool IsMouseOver { bool get(); };
public bool IsMouseOver { get; }
member this.IsMouseOver : bool
Public ReadOnly Property IsMouseOver As Boolean

Property Value


如果滑鼠指標位在這個項目或其子項目上方,則為 true;否則為 falsetrue if mouse pointer is over the element or its child elements; otherwise, false. 預設值為 falseThe default is false.



下列範例會建立一個樣式,其中包含屬性 setter,可在 Hyperlink 報表 IsMouseOver true時,提供替代的視覺行為。The following example creates a style that includes a property setter that gives an alternate visual behavior when a Hyperlink reports IsMouseOver true.

  <Trigger Property="Hyperlink.IsEnabled" Value="false">
    <Setter Property="Foreground" Value="Gray"/>
  <Trigger Property="Hyperlink.IsMouseOver" Value="true">
    <Setter Property = "Foreground" Value="{StaticResource BlueGreenBrush}"/>


雖然類似的 "IsMouseOverChanged" 事件不存在,但有數個類似的事件。Although an analogous "IsMouseOverChanged" event does not exist, several similar events do. 例如,您可以使用 MouseEnterMouseMoveIsMouseDirectlyOverChangedFor example, you can use MouseEnter, MouseMove, and IsMouseDirectlyOverChanged.

如果此專案捕捉滑鼠,此屬性會保持 true,直到滑鼠捕捉遺失,而且滑鼠指標離開元素界限為止。If this element captures the mouse, this property remains true until mouse capture is lost and the mouse pointer leaves the element bounds.

相依性屬性資訊Dependency Property Information

識別碼欄位Identifier field IsMouseOverProperty
設定為 true 的中繼資料屬性Metadata properties set to true NoneNone

Applies to