Hello,
I have noticed two separate issues when loading html documents into the WPF RadRichTextBox
The first issue is that loading a document with capitalized <STYLE> tags will not render at all, even if there are no styles specified.
The second issue is that the CSS style for "a:link, span.MsoHyperlink" that Microsoft Outlook adds to emails is being applied to the body tag of the resulting document. This causes all text within the RadRichTextBox to be underlined, not just hyperlinks.
I have created a sample application to reproduce these issues.
I have noticed two separate issues when loading html documents into the WPF RadRichTextBox
The first issue is that loading a document with capitalized <STYLE> tags will not render at all, even if there are no styles specified.
The second issue is that the CSS style for "a:link, span.MsoHyperlink" that Microsoft Outlook adds to emails is being applied to the body tag of the resulting document. This causes all text within the RadRichTextBox to be underlined, not just hyperlinks.
I have created a sample application to reproduce these issues.
<
Window
x:Class
=
"RadRichTextBoxTestApp.MainWindow"
Title
=
"MainWindow"
Height
=
"350"
Width
=
"525"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
SizeToContent
=
"WidthAndHeight"
>
<
Window.Resources
>
<
Style
TargetType
=
"{x:Type telerik:RadRichTextBox}"
>
<
Style.Setters
>
<
Setter
Property
=
"Height"
Value
=
"100"
/>
<
Setter
Property
=
"Width"
Value
=
"300"
/>
</
Style.Setters
>
</
Style
>
</
Window.Resources
>
<
Grid
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"Auto"
/>
</
Grid.RowDefinitions
>
<
telerik:HtmlDataProvider
RichTextBox
=
"{Binding ElementName=box0}"
Html
=
"{Binding DocumentWithCapitalizedStyleTags}"
/>
<
telerik:RadRichTextBox
Grid.Row
=
"0"
x:Name
=
"box0"
Margin
=
"10"
/>
<
telerik:HtmlDataProvider
RichTextBox
=
"{Binding ElementName=box1}"
Html
=
"{Binding DocumentWithLowerCaseStyleTags}"
/>
<
telerik:RadRichTextBox
Grid.Row
=
"1"
x:Name
=
"box1"
Margin
=
"10"
/>
<
telerik:HtmlDataProvider
RichTextBox
=
"{Binding ElementName=box2}"
Html
=
"{Binding DocumentWithMsoHyperlinkStyles}"
/>
<
telerik:RadRichTextBox
Grid.Row
=
"2"
x:Name
=
"box2"
Margin
=
"10"
/>
<
telerik:HtmlDataProvider
RichTextBox
=
"{Binding ElementName=box3}"
Html
=
"{Binding DocumentWithInlineHyperlinkStyles}"
/>
<
telerik:RadRichTextBox
Grid.Row
=
"3"
x:Name
=
"box3"
Margin
=
"10"
/>
</
Grid
>
</
Window
>
using System.Windows;
namespace RadRichTextBoxTestApp
{
/// <
summary
>
/// Interaction logic for MainWindow.xaml
/// </
summary
>
public partial class MainWindow : Window
{
public MainWindow()
{
DataContext = new MainWindowViewModel();
InitializeComponent();
}
}
public class MainWindowViewModel
{
public string DocumentWithCapitalizedStyleTags
{
get { return "<
html
><
head
><
STYLE
></
STYLE
></
head
><
body
>HELLO WORLD!</
body
></
html
>"; }
}
public string DocumentWithLowerCaseStyleTags
{
get { return DocumentWithCapitalizedStyleTags.Replace("<
STYLE
", "<style").Replace("</STYLE","</style"); }
}
public string DocumentWithMsoHyperlinkStyles
{
get
{
return
@"
<html><
head
><
style
>
a:link, span.MsoHyperlink
{mso-style-priority:99; color:blue; text-decoration:underline;}
</
style
></
head
><
body
>HELLO WORLD! <
a
href
=
""
http://telerik.com"">Telerik</
a
></
body
></
html
>
";
}
}
public string DocumentWithInlineHyperlinkStyles
{
get { return DocumentWithMsoHyperlinkStyles.Replace(", span.MsoHyperlink", ""); }
}
}
}