Ane*_*nee 5 wpf casting mouse-cursor
我有一个 System.Windows.Forms.Cursor ,想将其分配给 WPF 的 image.Cursor 属性,该属性恰好是 System.Windows.Input.Cursor 类型。这里的约束是,前一个 Cursor 类型是由我们的框架返回的,我无法修改它。有什么方法可以将前者转换为后者吗?
这对我来说很有效:
SafeFileHandle panHandle = new SafeFileHandle(System.Windows.Forms.Cursors.PanNorth.Handle, false);
this.Cursor = System.Windows.Interop.CursorInteropHelper.Create(panHandle);
Run Code Online (Sandbox Code Playgroud)
SafeFileHandle 的文档警告不要对第二个参数使用 false,但无论我使用 true,我都会得到 SEHExceptions(即使我使用 Cursors.PanNorth.CopyHandle())
| 归档时间: |
|
| 查看次数: |
1716 次 |
| 最近记录: |