FrameworkContentElement.ForceCursor 属性

定义

获取或设置一个值,该值指示此 FrameworkContentElement 是否应该强制用户界面 (UI)user interface (UI) 按照此实例的 Cursor 属性所声明的方式呈现光标。Gets or sets a value indicating whether this FrameworkContentElement should force the 用户界面 (UI)user interface (UI) to render the cursor as declared by this instance's Cursor property.

public:
 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

属性值

Boolean

在光标位于此元素上时,强制光标呈现以将此实例的设置用于光标(包括在所有子元素上),则为 true;否则为 falsetrue to force cursor presentation while over this element to use this instance's setting for the cursor (including on all child elements); otherwise false. 默认值为 falseThe default value is false.

示例

下面的示例在元素上强制游标。The following example forces the cursor while over the element.

<StackPanel
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
  <StackPanel Name="CursorForced" ForceCursor="true" Cursor="Hand">
    <Label>Cursors Forced</Label>
    <TextBox>Fill me in!</TextBox>
  </StackPanel>
  <StackPanel Name="CursorNotForced">
    <Label>Cursors Not Forced</Label>
    <TextBox>Fill me in!</TextBox>
  </StackPanel>
</StackPanel>

注解

将此属性设置为 true 将覆盖由子元素建立的游标首选项。Setting this property to true 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

适用于