ContentElement.IsMouseOver ContentElement.IsMouseOver ContentElement.IsMouseOver 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).

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

屬性值

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

實作

範例

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

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

備註

雖然類似"IsMouseOverChanged 」 事件不存在,便會執行數個類似的事件。Although an analogous "IsMouseOverChanged" event does not exist, several similar events do. 例如,您可以使用MouseEnterMouseMove,和IsMouseDirectlyOverChangedFor 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
若要設定的中繼資料屬性 trueMetadata properties set to true None

適用於