Answered by:
How to change cursor in XAML?

Question
-
I have a custom control looks like this:
At the end I have a customized Del-button, to be able to remove this item by pressing. This control is located in a RichTextBox, with many others, because this type of frame is allow to flow an objects left to right and top to bottom at the same time. My problem is a mouse cursor. When I move it over my control and particular Del-button it's stay the same as in RichTextBox, like this - I. But I need it to looks like narrow. So, I know that it's possible to set mouse cursor for control. At list in WPF it was possible. But I can't find this XAML setting to do it. I don't want to change the mouse time in a code by events. I want to set it once in XAML and forget it. How to do so?
Aleksey
Friday, December 13, 2013 5:19 AM
Answers
-
I don't think it's possible. If you want to change via code-behind, here you go.
private void MyTextBlock_PointerEntered_1(object sender, PointerEventArgs e) { Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Hand, 1); } private void MyTextBlock_PointerExited_1(object sender, PointerEventArgs e) { Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Arrow, 2); }
- Marked as answer by Newfriend Tuesday, December 24, 2013 9:44 AM
Friday, December 13, 2013 10:24 AM
All replies
-
I don't think it's possible. If you want to change via code-behind, here you go.
private void MyTextBlock_PointerEntered_1(object sender, PointerEventArgs e) { Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Hand, 1); } private void MyTextBlock_PointerExited_1(object sender, PointerEventArgs e) { Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Arrow, 2); }
- Marked as answer by Newfriend Tuesday, December 24, 2013 9:44 AM
Friday, December 13, 2013 10:24 AM -
You'll be smile, but this is not working with RichTextBox. Event firing, but mouse pointer still the same - I.
Aleksey
Friday, December 13, 2013 12:29 PM -
Hi Newfriend,
I think Xyroid provided a correct solution.
Here you have a user control, in which put a cancel button inside your RichTextBlock, you could modify the cursor style by PointEnter event fired while the mouse is hover the button. Or do I miss something? It should work with Windows Store App.
--James
<THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
Thanks
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.Tuesday, December 24, 2013 8:57 AMModerator