This is a migrated thread and some comments may be shown as answers.

The method "ClearValue" on Span object is gone in Q3

1 Answer 20 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
hwsoderlund
Top achievements
Rank 1
hwsoderlund asked on 17 Nov 2011, 04:59 PM
Code like the following does not work anymore:
private void HtmlDataProvider_SetupDocument(object sender, SetupDocumentEventArgs e)
{
    foreach (Span span in e.Document.EnumerateChildrenOfType<Span>())
    {
        span.ClearValue(Span.FontSizeProperty);
        span.ClearValue(Span.FontFamilyProperty);
        span.ClearValue(Span.FontStyleProperty);
        span.ClearValue(Span.FontWeightProperty);
    }
}

I have replaced it with the following:
private void HtmlDataProvider_SetupDocument(object sender, SetupDocumentEventArgs e)
{
    foreach (Span span in e.Document.EnumerateChildrenOfType<Span>())
    {
        if (span.Style != null)
        {
            span.Style.ClearPropertyValue(Span.FontSizeProperty);
            span.Style.ClearPropertyValue(Span.FontFamilyProperty);
            span.Style.ClearPropertyValue(Span.FontStyleProperty);
            span.Style.ClearPropertyValue(Span.FontWeightProperty);
        }
    }
}


Is this the correct way to solve the issue?

Best regards,
/Henrik

1 Answer, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 22 Nov 2011, 07:11 PM
Hello Henrik,

We had made the ClearValue method internal, as we have thought that it is not used. We will make sure to make it public again in the internal build next week.

For the time being, you can use the following approach, which has the same effect:

private void HtmlDataProvider_SetupDocument(object sender, SetupDocumentEventArgs e)
{
    foreach (Span span in e.Document.EnumerateChildrenOfType<Span>())
    {
        span.GetStyleProperty(Span.FontSizeProperty).ClearValue();
        span.GetStyleProperty(Span.FontFamilyProperty).ClearValue();
        span.GetStyleProperty(Span.FontStyleProperty).ClearValue();
        span.GetStyleProperty(Span.FontWeightProperty).ClearValue();
    }

Kind regards,
Iva Toteva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
RichTextBox
Asked by
hwsoderlund
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Share this question
or