If you want to use a custom mouse in XAML, simply set cursor = "/asserts/hand. Ani" in the label,
However, ifCodeThis. cursor = new cursor ("Mouse resource path") is required. Here, the [Mouse resource path] must use an absolute path,
This is not a problem. Another method is to use (I have not verified ):
Streamresourceinfo Sri = application. getresourcestream (New uri ("/assets/cursor/hand. ani ", urikind. relative); cursor customcursor = new cursor (SRI. stream); this. cursor = customcursor;
I don't feel very good, but I accidentally saw it on the Internet. A resource dictionary implementation method is as follows:
// Add to resources: <window. resources> <resourcedictionary> <textblock X: Key = "cursorgrab" cursor = "Resources/cursors/grab. cur "/> <textblock X: Key =" cursormagnify "cursor =" Resources/cursors/magnify. cur "/> </resourcedictionary> </window. resources>
// Example of embedded cursor referenced in code: If (selectedtool = "hand") mycanvas. cursor = (textblock) This. resources ["cursorgrab"]). cursor; else if (selectedtool = "magnify") mycanvas. cursor = (textblock) This. resources ["cursormagnify"]). cursor; else mycanvas. cursor = cursor. arrow;