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.
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 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...
How to display the large text in the richtextbox. I need to use with MVVM pattern.
Can anyone suggest me a wpf control to display large text or how to make the richtextbox to display entire content?
Richtextbox can display more than 1000 lines. I use the one for cat and it works just nice(with all the formatting and etc). May be you have vertical scroll OFF and you cant see the rest of the lines?! see Shoaib Shaikh answer with suggested properties values.
Rich text box can also have same properties to accept multiple lines as textbox does. in order to conditionally format some lines in red you will have to provide Flow document in RichTextbox. you can create flow document by xml. this is an article could be helpful
http://www.codeproject.com/KB/WPF/BindableWPFRichTextBox.aspx
I am currently working on a Silverlight project and I am using RichTextBox. User are allowed to drag and drop images on to the RTB. I know that the Xaml property a Silverlight RichTextBox doesn't not include any UIElement objects that are present in the content and I need to save the content of this RTB and later load it. Does anyone know of a way to achieve this? Thanks.
You're probably better off traversing the all of the Inlines in the RTB. The InlineUIContainers are Inlines so you can handle those however you'd like.
Your basic strategy should look something like:
Get the Blocks property of the RTB, find all the Paragraphs. Get the Inlines on each Paragraph. For each inline: handle a Run and save as Text. handle InlineUIContainer and save as however you'd like. Handle a Span as a recursive call to find the child Inlines.
If you want to save formatting on the Runs, then you'll have even more code for that.
It's not nearly as easy as using the Xaml property but it's really the only way to handle controls in InlineUIContainers.
I have a situation where I need to show a formatted text (normal, bold, highlighted) and should also be selectable so that user can copy the text.
I have used textblock where i can apply multiple formattings using Inline content flow elements but unfortunately it's text is not selectable.
Whereas Textbox allows to select text and copy to clipboard, it does not allow me to format text.
Is there anything I am missing or I'll have to build a custom control?
I'm not sure how much style you're wanting to apply, but I find the following site to be useful to determine the best way to use Silverlight controls:
http://samples.msdn.microsoft.com/Silverlight/SampleBrowser/index.htm#/
This specific URL has some information on how to style a Textbox:
http://samples.msdn.microsoft.com/Silverlight/SampleBrowser/index.htm#/?sref=TextBoxSnippet
You can use RichTextBox. It control is selectable and support formatted tex.