共用方式為


CoreCursor 類別

定義

定義資料指標 (視覺指標) 物件。

public ref class CoreCursor sealed
/// [Windows.Foundation.Metadata.Activatable(Windows.UI.Core.ICoreCursorFactory, 65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class CoreCursor final
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Activatable(Windows.UI.Core.ICoreCursorFactory, 65536, "Windows.Foundation.UniversalApiContract")]
class CoreCursor final
[Windows.Foundation.Metadata.Activatable(typeof(Windows.UI.Core.ICoreCursorFactory), 65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class CoreCursor
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.UI.Core.ICoreCursorFactory), 65536, "Windows.Foundation.UniversalApiContract")]
public sealed class CoreCursor
Public NotInheritable Class CoreCursor
繼承
Object Platform::Object IInspectable CoreCursor
屬性

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)

範例

本範例示範如何在指標位於按鈕上方時設定「手」游標。

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Button Content="Button 1"
            PointerEntered="Button_PointerEntered"
            PointerExited="Button_PointerExited"/>
</Grid>
public sealed partial class MainPage : Page
{
    CoreCursor buttonCursor = null;
    CoreCursor cursorBeforePointerEntered = null;

    public MainPage()
    {
        this.InitializeComponent();
        buttonCursor = new CoreCursor(CoreCursorType.Hand, 0);
    }

    private void Button_PointerEntered(object sender, PointerRoutedEventArgs e)
    {
        // Cache the cursor set before pointer enter on button.
        cursorBeforePointerEntered = Window.Current.CoreWindow.PointerCursor;
        // Set button cursor.
        Window.Current.CoreWindow.PointerCursor = buttonCursor;
    }

    private void Button_PointerExited(object sender, PointerRoutedEventArgs e)
    {
        // Change the cursor back.
        Window.Current.CoreWindow.PointerCursor = cursorBeforePointerEntered;
    }
}

備註

若要使用預先定義的 Windows 資料指標建立 CoreCursor 實例,請使用除了Custom以外的CoreCursorType列舉中可用的任何資料指標類型。 在此情況下,會忽略 Id 屬性。

若要使用自訂資料指標,請使用 CoreCursorType.Custom 列舉選項,並指定自訂資料指標的 識別碼 。 您可以將包含自訂資料指標的 .res 資源檔新增至專案,並使用 /win32res 編譯器選項將其包含在元件中。 識別碼是.res檔案中指定的資料指標資源識別碼

建構函式

CoreCursor(CoreCursorType, UInt32)

建立所提供資料指標類型的新 CoreCursor 實例。

屬性

Id

取得資料指標的資源識別碼。

Type

取得資料指標的類型。

適用於