Does anyone know a Windows Phone textbox control that binds to HTML property? I've used C1RichTextBox and it does the job but it's too damn slow! Please help.
The control from ComponentOne is the only one I'm aware of.
Where I've had to display HTML content in the past I've used one of the following two approaches.
Display the content in a WebBrowser control.
Manually parse the HTML and convert it into XAML controls.
The first option is appropriate when there is large amount of HTML to parse and when it is likely to vary greatly. (i.e. you can't be sure you'll only get a certain set of tags being used.)
If using the second option, be sure to consider using the HTML Agility Pack to help tidy up the HTML before parsing it.
A possible workaround is to put RichTextBox into a ScrollViewer to take advantage of the hardware accelerated control.
<ScrollViewer>
<c1:C1RichTextBox Height="1000" />
</ScrollViewer>
Related
This code snippet comes from RichEditBox style application,
Document.Selection.SetRange(paragraphStartIndex, paragraphStartIndex + data.Text.Length);
Document.Selection.CharacterFormat.Strikethrough = FormatEffect.On;
However, can we do similar things with a RichTextBlock?
I know that I can add a <run> or a <Span> and add style information to these elements, but is there any way to grab the whole RichTextBlock content and apply style to a range of text within it?
RichTextBlock and RichEditBox are rich text-related controls, but they are very different in display.
The process of RichEditBox displaying rich text is like drawing on paper, because it carries the modified function, so there is a complete Document as a carrier.
RichTextBlock is not responsible for modification, it is only responsible for display, so it is more like building blocks. RichTextBlock has a lot of display elements to render different visual effects, but they are independent of each other. You can't set effects for a certain character. You can only set the effect for the entire block (such as Paragraph).
When you select text in the RichTextBlock, you can get the parent element of the currently selected text point through RichTextBlock.SelectionStart.Parent or RichTextBlock.SelectionEnd.Parent, and set the effect.
Best regards.
Is it possible to access the TextBlock Template to change the border and make it curved?
I tried editing the Template through Blend but with no success.
I'm trying to achieve something like this (couldn't get that given solution working):
Curve TextBlock in Windows 8
I'm trying to do this in C#/XAML - WINRT (Windows 8.1)
I don't think a TextBlock has a template you could modify. It's probably just some parameters used to tell DirectWrite what text to render and with what properties. The easiest way to solve it is when your text is constant to just break it apart into multiple single letter TextBlocks and lay them out on a path using Blend or Illustrator. If don't control what text can show up on the path - you'd have to code up the layout algorithm. Chris's link seems like a good place to start.
There isn't a clean way to do this directly in Xaml. Like Filip says, you can approach it by breaking the letters apart. That can work well for long sentences with small letters, but can be pretty chunky with large or connected letters. If you need smoother rendering then you can interop to Direct2D.
MSDN has a Direct2D animated text on a path sample which you could combine with the XAML SurfaceImageSource DirectX interop sample
I am trying to load a rtf file in a windows store app, however this file comes with a style and sometimes that style is applied and ohter times isn't. This behaviour is TOTALLY random (If I rerun the app over and over again sometimes the container I am using uses the style, other doesn't).
I am using a RichEditBox only because RichTextBlock doesn't support rtf files.
I have a RichEditBox in the MainPage.xaml
<Grid>
<RichEditBox
x:Name="InfoContentView"
VerticalAlignment="Stretch"
BorderThickness="0"
Background="{x:Null}"
Foreground="#FFFFFF"/>
</Grid>
And then I inject the rtf file like this:
this.InfoContentView.IsReadOnly = false;
this.InfoContentView.Document.SetText(Windows.UI.Text.TextSetOptions.FormatRtf,
textContent);
this.InfoContentView.IsReadOnly = true;
Textcontent is loaded from application package. I supose that works since I see the text perfectly, even links work fine.
I have tried to put the Document text before each execution to empty. Also, I have added a button to refresh the behaviour and it doesnt work in the first execution but then, after I press the button several times, it is consistent.
I only wish that the behaviour is consistent. I don't care if I have to format the file in the file or in the application.
The rtf file is quite simple and you can download the rtf file here.
Well, this is ackward. I don't know if this is a bug or if I shouldn't be doing this.
This grid was inside another grid that had Visibility = Collapsed. It turns out that if I had the Visiblity equals to collapsed and then I change it to visible it would have this random behaviour. I have hidden it using the opacity and then it works. Although with this solution I had to do some hacky stuff so I could get touches in that area when the opacity is set to 0.
I am not satisfied with my answer, but it might save someone else time. I will accept any answer that explains this behaviour.
How do I get the text out of a Silverlight 4 RichTextBox without the formatting? I know the Xaml property will give me the XAML but I just want the text.
This is a little late, but I will post anyway. There is a trick that involves selecting all the text in code and then accessing the Text propety of the TextSelection object. Like so:
myRichTextBox.SelectAll();
var plainText = myRichTextBox.Selection.Text;
I am using it in my apps and although it is not the prettiest solution, it works. Found it here:
http://forums.silverlight.net/forums/p/184560/422007.aspx
If you just want text, why not use TextBox instead?
There are various third-party components that support this kind of functionality (unfortunately paid). For example, Telerik's RadRichTextBox supports both highlighting and exporting rich text content as plain text, latter trough component called TxtFormatProvider.
I am wondering if it is possible to create tiff/eps image from XAML in WPF.
We are looking for printing high resolution images from existing XAML in WPF.
Please let me know if you have any suggestions.
Depending on what exactly you're trying to do you might want to look at the xsl-fo stuff. The goal of creating printable markup is the same but fo uses xml instead of xaml. Depending on your requirements you might be able to create xsl-fo directly instead of xaml. If not, I'm pretty sure you can find xaml to svg translators (there are lots that go from svg to xaml) and I know that xsl-fo can handle svg. For the last step of taking the xsl-fo to tiff I've used the Ecrion software but I'm sure there are others by now that also do a good job. Hope that helps...