Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
445
How to change the default way to follow the hyperlink?
posted

I like to change the default way of following link in RichtextEditor. 

Currently the default is Ctrl + Click. But I want to change it as direct Click with changing of mouse shape to hand finger-like.

thanks a lot in advance

Parents
  • 530
    Offline posted

    Hello James.Jeon,

    You can call Process.Start method to open a link when you click hyperlink text.

            private void editor1_PreviewMouseDown(object sender, MouseButtonEventArgs e)
            {
                var adornmentLayer = e.OriginalSource as AdornmentLayer;
                if(adornmentLayer != null)
                {
                    Process.Start(targetUrl);
    
                    e.Handled = true;
                }
            }
    

    For the mouse cursor, you can change the style by setting Mouse.OverrideCursor.

            private void editor1_MouseMove(object sender, MouseEventArgs e)
            {
                var adornmentLayer = e.OriginalSource as AdornmentLayer;
    
                if (adornmentLayer != null)
                {
                    Mouse.OverrideCursor = Cursors.Hand;
                }
                else
                {
                    Mouse.OverrideCursor = Cursors.Arrow;
                }
            }
    

    Please refer to the attached sample for details.

    Best regards,
    Yuki Mita
    Developer Support Engineer
    Infragistics Inc.
    www.infragistics.com/support

    WpfApplication5.zip
Reply Children