Home > DeveloperSection > Forums > WPF RichTextBox Image Link issue
Brad Pitt
Brad Pitt

Total Post:61

Points:429
Posted on    September-23-2013 8:07 AM

 WPF
Ratings:


 1 Reply(s)
 1137  View(s)
Rate this:

I am loading a .rtf file into a WPF Rich TextBox and my images that have links are getting this underline property added. I do not want the underline and cant seem to get rid of it.

              public MainWindow()

    {

        InitializeComponent();

        Assembly assembly = Assembly.GetExecutingAssembly();

        Stream s =  assembly.GetManifestResourceStream("WPFRichTextIssue.Sigs.MSC.rtf");

        using (s)

        {

             TextRange TR = new TextRange(RTB.Document.ContentStart, RTB.Document.ContentEnd);

        TR.Load(s, DataFormats.Rtf);

        }

    }

I have tired to find the underlined images with

  if (TR.GetPropertyValue(Inline.TextDecorationsProperty) == TextDecorations.Underline)

            {

            }

            else

            {

                // Do something

            }

But the Image is not Inline.Text so it does not find it... Any help would be great.



Pravesh Singh

Total Post:411

Points:2881
Posted on    September-23-2013 8:32 AM

Hi Brad,

Looking in your XAML, just after the RTB opening tag that looks something like this:

<RichTextBox x:Name="RTB_Reply" HorizontalAlignment="Left" Height="157" Margin="302,338,0,0" VerticalAlignment="Top" Width="488" IsReadOnly="True">

Paste this:

<RichTextBox.Resources>

    <Style TargetType="{x:Type Hyperlink}">

        <Setter Property="TextDecorations"  Value="{x:Null}"/>

    </Style>

</RichTextBox.Resources>


Don't want to miss updates? Please click the below button!

Follow MindStick