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

Property Value


如果强制光标在位于此元素(包括所有子元素)上时的呈现使用光标的当前 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 更适用于控件子类或复合方案。Setting ForceCursor is more appropriate in control subclassing or compositing scenarios.

依赖项属性信息Dependency Property Information

标识符字段Identifier field ForceCursorProperty
元数据属性设置为 trueMetadata properties set to true None

Applies to

See also