我正在尝试在 Cursor 上使用自定义图像,并使用这些代码做到了。
public static class cursorHelper
{
public static Cursor vertical = new Cursor(Application.GetResourceStream(getFromResource("PenCADwpf", "Images/cursors/Vertical.ico")).Stream);
public static Cursor horizontal = new Cursor(Application.GetResourceStream(getFromResource("PenCADwpf", "Images/cursors/Horizontal.ico")).Stream);
public static Uri getFromResource(string psAssemblyName, string psResourceName)
{
Uri oUri = new Uri("pack://application:,,,/" + psAssemblyName + ";component/" + psResourceName, UriKind.RelativeOrAbsolute);
return oUri;
}
public static ImageSource getImageSourceFromResource(string psAssemblyName, string psResourceName)
{
Uri oUri = getFromResource(psAssemblyName, psResourceName);
return BitmapFrame.Create(oUri);
}
}
Run Code Online (Sandbox Code Playgroud)
在代码中使用的是
private void btnVerticalMullion_Click(object sender, RoutedEventArgs e)
{
this.Cursor = cursorHelper.vertical;
}
Run Code Online (Sandbox Code Playgroud)
我的问题是光标的热点是左下角。我需要将其更改为图像的 0,0(左上角)点。请问有人可以帮助我吗?提前致谢,