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...
Related
Actually, I want to display a string of HTML inside my Silverlight application. I haven't found any solutions that work. I read there is a control that can do this, but it only works if the SL application is out of browser, which is not an option for me. So I thought I could convert the HTML to XAML using Microsoft's example classes found here:
https://msdn.microsoft.com/en-us/library/aa972129.aspx
And then have a RichTextBox control, whose Xaml property I would set to the XAML string. However, this throws an ArgumentException with the text "Value" (not too helpful). It seems that when you set this Xaml property, it's quite picky what would qualify as acceptable XAML. My HTML isn't too fancy. It has several tables (tr and td elements). Here's an example of XAML that does work to set to the RichTextBox's XAML property:
<Section xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"><Paragraph>Blah</Paragraph></Section>
Here's an example of the XAML that I tried to set to the RichTextBox's XAML property that does NOT work:
<FlowDocument xml:space="preserve" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"><Table></Table></FlowDocument>
I tried replacing "FlowDocument" with "Section", and that didn't work either. It doesn't like the "Table" element in the XAML.
Are there any other ways to accomplish what I want to do?
thanks
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
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.
Today i'm working on simple html editor in visual c#.
My goal is to open pure html file from local drive (Opendialog load into string or load into webbrowser completed) and allow to edit key fragments.
application should find specific divs and return the full content of that div to textbox or better to combobox (compare to combobox item and show it).
if i change the textbox (or pick up another item from combobox) application should present changes on webbrowser control.
Then i need to print this html as is seen on webbrowser control.
Last thing is to save modified hmtl overwrting original and adding comment with changes at bottom of the html file.
I want to know how to perform search&replace in this project? How to "adress" content of a div?
Better is string searching, indexof, string.replace etc. Or drown into DOM-thing (i don't know both at the moment).
How to present changes on html preview on webcontrol component? And finally overwrite a file?
Code's examples appreciated :)
Thanks in advance
You should use HtmlAgilityPack for that, it makes working with DOM a lot more easier, than parsing it yourself.
http://htmlagilitypack.codeplex.com/
For example, here is how to get all divs
var elements = hdoc.DocumentNode.Descendants("div") /.Where(.your conditions..))/;
I want to be able to read text from a Silverlight TextBlock (TextBlock Control) (Silverlight & C#) and check what formatting (as in: bold, italic, font size, etc...) has been applied to it, so I can store it in an XML file.
Is it possible to find out what formatting has been applied to a piece of text with C# and Silverlight so it can be stored and re-used later? The text would be contained within a textbox or textblock control.
Storage used can be XML but I've just found out Silverlight doesn't support XSL, so just XML.
Regards,
T
Just make sure you give your control a name.
<Textblock x:Name="myTextBlock" />
In your code behind you can then access the TextBlock but calling it's name (myTextBlock).
Here you can add logic like:
if (myTextBlock.FontWeight == "Bold")
{
//Do Something
}
From reading your needs you'll most likely be passing the object to a function and creating your xml file from there. Good luck.
By formatting you mean a phone number or date format?
If yes. Use regular expressions.
Take a look at the System.Text.RegularExpressions namespace. Everything there should help you.