I have a RichTextBox in a WPF application (C#.NET4.5). The RichTextBox is in Rtf format. I'm using a MarkupConverter to convert and save the RichTextBox.Text Rtf text back in the Db as Html. If a user opens an existing record, the markup converter converts from Html back into Rtf for display in the UI. All works well.
I have an issue trying to handle Hyperlinks. Because the Markup Converter has to convert from Rtf-Xaml-Html I don't believe that there is a Xaml tag which equates to Href or HYPERLINK as there is in Html or Rtf?
Therefore the converter is just stripping out the hyperlink.
Is there any way to handle this in Xaml?
Thanks
Related
So I am trying to display HTML from a column in an access DB. I am able to do this using this below.
webBrowser1.DocumentText = dataGridView1.Rows[1].Cells[3].Value.ToString();
The problem is I want the control to be "transparent" basically show the text with html formatting but show the form background behind it... and I have not found a way to do that.
Is there another way to display this HTML while showing the form background and keep the format of the contents? The HTML is just text with li tags etc.
Have you tried applying a style to the stored HTML? You can make things transparent, or coloured using a CSS style.
I try to get HTML-Text in a TextBock without HTML-Tags. DO anyone know, if it is possible to show html-Text in a TextBlock Control? Have I to use a WebBrowser Control for this case. I use simple HTML-Tags to format Text like Textalignment or Textdecorations.
Here is a example of my HTML-Text:
Headline for TestingDescriptions
I think you can try two different approaches:
Simply display the HTML content in a WebBrowser control. This has
multiple disadvantages, such as not being able to be transparent,
and its performance can be quite disappointing.
Convert your HTML content to
XAML FlowDocument, which you can display natively in a TextBlock. You can find more information about how to convert
here.
I have flipView in sample itemDetailPage and I have text in string which has html tags (bold, italics). I want this string shows in richTextBlock in flipView but I don´t know how. I was searching for converters between HTML and XAML and there aren´t working with WinRT. I was looking into source codes and searching for answers and I can convert my html string to xaml string. It looks like
<FlowDocument xml:space=\"preserve\" xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"><Paragraph>Start<Run>i--</Run> something <Run>i++</Run> end of paragraph.</Paragraph><Paragraph>\n\n</Paragraph><Paragraph>Another paragraph <Run>anything</Run>. And ending.</Paragraph><Paragraph>\n\n</Paragraph></FlowDocument>
But when I this bind to Text property of RichTextBlock it just shows as text without formatting. So how can I format text in RichTextBlock? I know it´s possible to do this with adding textblocks but in FlipView I don´t how access to richTextBlock. I want to use RichTextBlock and I don´t want to change it for WebView or some WebControls (I like column sorting in RichTextBlock).
Yeah, this problem has been ongoing. Vincent H had a good start with an xslt conversion. I recently took his start and expanded it using the Html Agility Pack. My main impetus was dealing with really badly formed Html and I think I got something at least minimally useful...
I am using tinyMCE editor. I have rtf formatted string in database column which I want to show in the browser editor i.e. tinyMCE. So that, user will edit the text as he wants. But for that I found I need to convert the rtf string in to xml to see it, since my tinyMCE is showing xmls properly. I am able to show the text from rtf string but I misses out the formatting like bold text, red colored text, \n etc. I want to retain all this formatting. How shall I retain the formatting or how shall I display the rtf text with the formatting or how shall I convert rtf text in to xml properly? I want to display rtf text like I am saving it in some rtf file and opening that file in ms word or open office word that way I want to see the format. rtf is Rich Text format.
You should convert your RTF to HTML and use that for TinyMCE, here is a code project article that will get you started :
http://www.codeproject.com/Articles/27431/Writing-Your-Own-RTF-Converter
I'm using dynamic RichTextBox control in C# 2.0 and I want to insert "\scaps" in RTF so that if the file is saved programatically and then opened in MS-Word certain text be seen smallcaps.
Can anyone tell me the code as how to insert the tag?
Well, you can access the rich text directly through the Rtf property on the rich text box.