Richtextblock with hyperlinkbuttons - problem: mouse cursor doesn´t change properly on mouseover RRS feed

  • Question

  • I downloaded the WinRT Toolkit and was good hope that I would be able to change the Cursor when the mouseover event is triggered, but the Cursor is only changed to "Hand" for some milliseconds, afterwards the "Default" Cursor is shown again.

    Is there any way to achieve the "Hand cursor" on mouseover of the Hyperlink button in a richtextblock? (like in the Default Messages app)

    Code Snippet:

    RichTextBlock textBlock = new RichTextBlock();

    var paragraph = new Paragraph();

    var runs = new List<Inline>();

    var link = new HyperlinkButton();

    FrameworkElementExtensions.SetSystemCursor(link, CoreCursorType.Hand);

    • Edited by mysms Monday, September 9, 2013 12:29 PM
    Monday, September 9, 2013 12:27 PM

All replies

  • You should be able to handle this yourself, just search the forum for this question as we're gone over this previously.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Monday, September 9, 2013 7:27 PM
  • I searched the Forum also before and I could only find following code which doesn´t fix my Problem. The Problem only occurs when a hyperlinkbutton is embedded in a richtextblock. 

    private void HyperlinkButton_PointerEntered_1(object sender, Windows.UI.Xaml.Input.PointerEventArgs e)
    Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Hand,1);

    private void HyperlinkButton_PointerExited_1(object sender, Windows.UI.Xaml.Input.PointerEventArgs e)
    Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Arrow, 1);

    When I move over a Hyperlink I can see the "Hand Cursor" for some milliseconds, but then the richtextblock seems to overwrite the Hand with the text Cursor. So the solution I found only works if the Hyperlink Button is not embedded in a richtextblock.

    If there is a solution for exactly the Problem I am facing, please provide a link or some description how to make progress.

    Tuesday, September 10, 2013 7:34 AM