C# WPF Bring element topmost (even over mouse)?
-
Saturday, April 14, 2012 3:23 AM
Hi Guys, I'm working on a project where I'm making an element(or image) follow the mouse on certain events. However, it does block the mouse from other objects preventing it from triggering mouse over or down events. I'd like to know if there's a way around this or even if it's possible to place an element OVER the mouse cursor so it won't block it.
I honestly haven't seen one implemented but it's worth asking than cropping the image(gif animation with 61 frames) into 4 parts(244 images >.<) so the mouse won't be obstructed.
Thanks
-Laurence
- Moved by CoolDadTxMVP Monday, April 16, 2012 2:11 PM WPF related (From:Visual C# General)
All Replies
-
Saturday, April 14, 2012 7:25 AM
I think that if you create a “hole” inside your element (a single pixel would be enough), then the mouse messages will be sent to other objects. Check if this article helps: http://chriscavanagh.wordpress.com/2009/03/16/wpf-rounded-corners-and-holes/.
Alternatively consider making custom cursors.
-
Monday, April 16, 2012 12:39 PM
The image I'm placing in the mouse is a GIF animated through C# code. It's in PNG and unfortunately, transparency in the image doesn't help to I might just crop each 61 images into 4(top, bottom, left and right) leaving a hole in the middle. I did try making my own cursor. Unfortunately, the max is 48px but I need it at 100px.
-
Thursday, April 19, 2012 7:12 AMModerator
Hi LaurenceDCM,
I agree to use your own custom cursor should be the best choice for you. But I don't understand what you said cursor's max size is 48px. Do cursor size with this kind of limitation?
You can just use this tool to convert .png image to .cur files, then use it like this.Cursor = yourcursor.cur to achieve your goal.
The idea from this post:http://social.msdn.microsoft.com/Forums/ar/wpf/thread/a58eb8b1-1100-48d9-aaa6-7534f041fc82
Hope it helps.
If you have any additional questions, please feel free to let me know.
Have a nice day.
Annabella Luo[MSFT]
MSDN Community Support | Feedback to us
- Marked As Answer by Annabella LuoModerator Thursday, April 26, 2012 5:53 AM
-
Thursday, April 26, 2012 5:53 AMModeratorWe are temporarily marking this as "Answer", if you have any concerns or new findings; please feel free to let me know.
Best regards.Annabella Luo[MSFT]
MSDN Community Support | Feedback to us
-
Monday, April 30, 2012 11:44 AMHi. I did resort to using that tool and just use a 48x48 cursor instead. However, if I use that code, "this.Cursor =......", the cursor is 32x32. How do make it use the 48x48 variant also present in the .ICO file instead? Thanks a lot by the way.

