Clearing text in span

6 posts, 0 answers
  1. Jennifer
    Jennifer avatar
    7 posts
    Member since:
    Mar 2009

    Posted 16 Aug 2010 Link to this post

    I am saving the XAML for a RadDocument in a database. I would like to replace certain text with inlineUIElements. I am able to find the text and add the elements (textboxes), but when I try to set the old span text to an empty string the Text property remains unchanged. 
    tempSpan.Text = "";

    I have also tried to remove the Span from the Paragraph, but this gives a not implemented error:
    tempPara.Children.Remove(tempSpan)

    I also tried creating a new RadDocument by iterating through sections, paragraphs, and spans. For the span including the substitution I tried to write the new elements, and for the others to just copy the old elements. The Style didn't seem to come through. The following is the sample that I am working with, and incidentally, the first apostrophe does not work, while the second does.

    <t:RadDocument version="1.0" LayoutMode="Flow" PageViewMargin="0,0" DefaultPageLayoutSettings="800,1140" ParagraphDefaultSpacingAfter="0" SectionDefaultPageMargin="6,6,6,6" xmlns:t="clr-namespace:Telerik.Windows.Documents.Model;assembly=Telerik.Windows.Documents" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
        <t:Section PageMargin="6,6,6,6">
          <t:Paragraph SpacingAfter="0">
            <t:Span Text=" This is a " FontFamily="Verdana"></t:Span>
            <t:Span Text="test" FontFamily="Verdana" UnderlineDecoration="Line" ForeColor="#FFFF0000" HighlightColor="#FFFFFF00"></t:Span>
            <t:Span Text="." FontFamily="Verdana" ForeColor="#FFFF0000" HighlightColor="#FFFFFF00"></t:Span>
          </t:Paragraph>
          <t:Paragraph SpacingAfter="0"></t:Paragraph>
          <t:Paragraph SpacingAfter="0">
            <t:Span Text="And " FontFamily="Verdana"></t:Span>
            <t:Span Text="another" FontFamily="Verdana" FontWeight="Bold"></t:Span>
            <t:Span Text="." FontFamily="Verdana"></t:Span>
          </t:Paragraph>
          <t:Paragraph SpacingAfter="0"></t:Paragraph>
          <t:Paragraph SpacingAfter="0">
            <t:Span Text="A third." FontFamily="Verdana"></t:Span>
          </t:Paragraph>
          <t:Paragraph SpacingAfter="0"></t:Paragraph>
          <t:Paragraph SpacingAfter="0">
            <t:Span Text="I wonder what would happen here |{60C5C54E-0230-DE11-A1B0-0003FF4E47B3}| if this got so terribly long. Don&apos;t know. Let&apos;s find out if this works." FontFamily="Verdana"></t:Span>
          </t:Paragraph>
        </t:Section>
      </t:RadDocument>


    Is this possible to do, and if so, what is the correct method?

    Thank you,

    Jennifer
  2. Ivailo Karamanolev
    Admin
    Ivailo Karamanolev avatar
    276 posts

    Posted 17 Aug 2010 Link to this post

    Hello Jennifer,

    We couldn't reproduce your issues - neither with Remove, nor with the apostrophes. Can you please send us a project which demonstrates these problems so we can further assist you?

    Best wishes,
    Ivailo
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Jennifer
    Jennifer avatar
    7 posts
    Member since:
    Mar 2009

    Posted 17 Aug 2010 Link to this post

    Thank you for your help. I submitted the sample project as a support ticket. Ticket ID is : 339371

    Jennifer
  4. Ivailo Karamanolev
    Admin
    Ivailo Karamanolev avatar
    276 posts

    Posted 17 Aug 2010 Link to this post

    Hello Jennifer,

    Thank you, I'll address your issues in the respective ticket.

    All the best,
    Ivailo
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Kjell
    Kjell avatar
    283 posts
    Member since:
    Jun 2010

    Posted 24 Jan 2011 Link to this post

    I'm having a similar problem.  I basically just need the richtextbox to behave like a regular textbox + have spellcheck.  I'm trying to keep it as simple as possible, so I'm just using one span and setting the .text value.  The problem is I also can't clear the span or even set it to " ".  I can set it to "  " but this is causing other weird problems. 
  6. Ivailo Karamanolev
    Admin
    Ivailo Karamanolev avatar
    276 posts

    Posted 27 Jan 2011 Link to this post

    Hi Kjell,
    The best and probably easiest thing, especially for your case when you need no formatting is to use:
    radRichTextBox.Document = new TxtFormatProvider().Import(documentText);
    This will create a new RadDocument containing documentText in a single Span (assuming no new lines in the string). Since you have no formatting information, nothing will be lost and the desired text will be shown. Just make sure to disable the floating mini toolbar and all other formatting UI so things don't get messed up.
    Let us know if you require additional assistance.

    Best wishes,
    Ivailo
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Back to Top