I want to use an image or icon as a custom cursor in WPF app. What's the best way to do it?
相关问题
- Views base64 encoded blob in HTML with PHP
- How to get the background from multiple images by
- Generic Generics in Managed C++
- VNC control for WPF application
- How to Debug/Register a Permanent WMI Event Which
相关文章
- .net中MessageBox.Show使用问题
- IdentityServer 报错:"idp claim is missing"
- 在 IdentityServer 中如何给 id token 添加更多信息
- WPF:如何在Trigger里修改Orientation?
- IdentityServer 的 Selector 在哪个 nuget 包
- 使用 IdentityServer 的项目遭遇错误:"IDX20803: Unable to obt
- ASP.NET Core ConfigureServices 中从 appsettings.json
- WPF aforge 怎么做一个 圆形的播放器
Like Peter mentioned above, if you already have a .cur file, you can use it as an embedded resource by creating a dummy element in the resource section, and then referencing the dummy's cursor when you need it.
For example, say you wanted to display non-standard cursors depending on the selected tool.
Add to resources:
Example of embedded cursor referenced in code:
-Ben
A very easy way is to create the cursor within Visual Studio as a .cur file, and then add that to the projects Resources.
Then just add the following code when you want to assign the cursor:
Also check out Scott Hanselman's BabySmash (www.codeplex.com/babysmash). He used a more "brute force" method of hiding the windows cursor and showing his new cursor on a canvas and then moving the cursor to were the "real" cursor would have been
Read more here: http://www.hanselman.com/blog/DeveloperDesigner.aspx
It may have changed with Visual Studio 2017 but I was able to reference a .cur file as an embedded resource:
To use a custom cursor in XAML I altered the code Ben McIntosh provided slightly:
To use the cursor just reference to the resource:
You could try this