CoreCursor 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
定义光标 (视觉指针) 对象。
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
- 继承
- 属性
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 实例,请使用 CoreCursorType 枚举中除 Custom 以外的任何可用游标类型。 在这种情况下, 将忽略 Id 属性。
若要使用自定义游标,请使用 CoreCursorType.Custom 枚举选项,并指定自定义游标的 ID 。 可以将包含自定义游标的 .res 资源文件添加到项目,并使用 /win32res 编译器选项将其包含在程序集中。 ID 是在 .res 文件中指定的游标资源 ID。
构造函数
CoreCursor(CoreCursorType, UInt32) |
创建所提供的游标类型的新 CoreCursor 实例。 |
属性
Id |
获取游标的资源 ID。 |
Type |
获取游标的类型。 |