FrameworkElement.ForceCursor 屬性

定義

取得或設定值,這個值表示這 FrameworkElement 是否應該強制使用者介面 (UI) 轉譯資料指標,如 屬性所 Cursor 宣告。

C#
public bool ForceCursor { get; set; }

屬性值

Boolean

如果游標位於此項目上方時,強制游標展示使用目前游標的 Cursor 設定 (包括在所有子項目上) 則為 true,否則為 false。 預設值是 false

範例

下列範例會強制資料指標值。

XAML
<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 ,將會覆寫子項目所建立的資料指標喜好設定。 在一般應用程式 UI 中這麼做可能會對使用者造成混淆,特別是當子項目嘗試指定資料指標時。 在控制項子類別化或撰寫案例中,設定 ForceCursor 更適合。

相依性屬性資訊

識別碼欄位 ForceCursorProperty
中繼資料屬性設定為 true

適用於

產品 版本
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
Windows Desktop 3.0, 3.1, 5, 6, 7

另請參閱