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.

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

属性值

如果强制光标在位于此元素(包括所有子元素)上时的呈现使用光标的当前 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
  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 , 则将覆盖由子元素建立的游标首选项。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 NoneNone

适用于

另请参阅