FrameworkElement.ForceCursor FrameworkElement.ForceCursor FrameworkElement.ForceCursor FrameworkElement.ForceCursor Property


取得或設定值,這個值表示此 FrameworkElement 是否應強制使用者介面 (UI)user interface (UI) 呈現游標,如 Cursor 屬性所宣告。Gets or sets a value that indicates whether this FrameworkElement should force the 使用者介面 (UI)user interface (UI) to render the cursor as declared by the Cursor property.

 property bool ForceCursor { bool get(); void set(bool value); };
public bool ForceCursor { get; set; }
member this.ForceCursor : bool with get, set
Public Property ForceCursor As Boolean


如果游標位於此項目上方時,強制游標展示使用目前游標的 Cursor 設定 (包括在所有子項目上) 則為 true,否則為 falsetrue if cursor presentation while over this element is forced to use current Cursor settings for the cursor (including on all child elements); otherwise false. 預設值為 falseThe default value is false.


下列範例會強制資料指標的值。The following example forces the cursor value.

  <StackPanel Name="CursorForced" ForceCursor="true" Cursor="Hand">
    <Label>Cursors Forced</Label>
    <TextBox>Fill me in!</TextBox>
  <StackPanel Name="CursorNotForced">
    <Label>Cursors Not Forced</Label>
    <TextBox>Fill me in!</TextBox>


如果您將這個屬性設定為true您將會覆寫的子項目所建立的資料指標喜好設定。If you set this property to true you will override the cursor preferences established by child elements. 因此一般應用程式這麼做UIUI可能會造成混淆使用者,特別是如果子元素正嘗試將指定資料指標。Doing so in general application UIUI might be confusing for the user, particularly if child elements are attempting to specify cursors. 設定ForceCursor在控制項的子類別化或複合 (compositing) 的情況下更適合。Setting ForceCursor is more appropriate in control subclassing or compositing scenarios.

相依性屬性資訊Dependency Property Information

識別項欄位Identifier field ForceCursorProperty
若要設定的中繼資料屬性 trueMetadata properties set to true None