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

RadRichTextBox.CurrentSpanStyle property not in Q2 release

6 Answers 148 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
GEB
Top achievements
Rank 1
GEB asked on 14 Jul 2010, 11:50 PM
In the beta version, the sample used the CurrentSpanStyle property of the RadRichTextBox.  However, in the Q2 release, this property was not carried forward.  Given a RadRichTextBox control, how do I now determine the current span style at any given time?

Here is a snippet of code from you beta example that no longer works in Q2. 

private void UpdateStyleButtons()
{
    if (this.Editor.Document.Selection.IsEmpty)
    {
        Span span = this.Editor.CurrentSpanStyle;
        this.ItalicButton.IsChecked = span.FontStyle == FontStyles.Italic;
        this.BoldButton.IsChecked = span.FontWeight == FontWeights.Bold;
        this.SubscriptButton.IsChecked = span.BaselineAlignment == BaselineAlignment.Subscript;
        this.SuperscriptButton.IsChecked = span.BaselineAlignment == BaselineAlignment.Superscript;
        this.StrikethroughButton.IsChecked = span.Strikethrough;
        this.UnderlineButton.IsChecked = span.Underline;

6 Answers, 1 is accepted

Sort by
0
Paul Dhingra
Top achievements
Rank 1
answered on 15 Jul 2010, 01:00 PM
Geb I think you and I are stuck in the same spot (hence my request for updated example code in my other thread) - looks like there were some other minor changes (not yet documented?), also including the change from PageLayoutSettings to DefaultPageLayoutSettings (which I'm hoping is the same thing but not 100% sure).

Anyway, also posting here because for me, it looks like the CurrentSpanStyle property still exists, but isn't accessible:

Error 1 'Telerik.Windows.Controls.RadRichTextBox.Friend ReadOnly Property CurrentSpanStyle As Telerik.Windows.Documents.Model.Span' is not accessible in this context because it is 'Friend'. 
0
GEB
Top achievements
Rank 1
answered on 15 Jul 2010, 02:46 PM
Another breaking change: the ChangeTextBackColor() method looks like it has changed to ChangeTextHighlightColor(). I think this is a good change in that it better describes the method. 

Also, I have noticed that when a change is made via these methods, they show the highlighting on the screen (e.g., yellow highlight background), but the color is not shown when printing.  At least this was the case with the Beta version.  I'm not sure if this is a bug, or by design.  I would prefer that if it's shown on the screen, then it is also shown when printing and previewing.  I have not been able to fully test yet with the Release version in that I need to get past the CurrentSpanStyle issue.
0
Alex
Telerik team
answered on 16 Jul 2010, 10:42 AM
Hello GEB,

There are indeed some breaking changes in the API since the Beta. Currently we are working on bringing all the help articles and resources up-to-date.

The good news is that you still have access to the "CurrentSpanStyle". We introduced a new property called CurrentEditingStyle which is of type StyleDefinition. There you can find all the properties previously contained in the CurrentSpanStyle. The way properties are accessed in the StyleDefinition class is much like how you work with DependencyProperties. Here is for example how you get the FontWeight property:

StyleDefinition sd = radRichTextBox.CurrentEditingStyle;
FontWeight currentFontWeight = (FontWeight)sd.GetPropertyValue(Span.FontWeightProperty);

If you want to use strongly typed properties, you can create a new Span instance, load all its properties form the style in the following way:


var span = new Span();                 span.CopyPropertiesFromStyle(this.radRichTextBox.CurrentEditingStyle);

I hope this clarifications will help. If you have more questions, please don't hesitate to ask.

Kind regards,
Alex
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
0
GEB
Top achievements
Rank 1
answered on 16 Jul 2010, 03:37 PM
Alex, your recommended changes now fix my problem.  Thank you very much for the clarifications. 
0
namratha
Top achievements
Rank 2
answered on 11 Nov 2010, 11:05 AM
hi i have downloaded the source code provided by the telrik team ,and i am using q2 series dlls the example downloaded is giving me many errors like 'style.GetPropertyValue(Span.FontWeightProperty)' has some invalid argements and i am not able to access using Telerik.Windows.Documents.Span namespace .please can any one help me its urgent

thanks in advance
regards 
namratha
0
Iva Toteva
Telerik team
answered on 12 Nov 2010, 11:00 AM
Hello Namratha,

Could you check if you have referenced Telerik.Windows.Documents and have added the following using declarations:

using Telerik.Windows.Documents.Model;
using Telerik.Windows.Documents.Model.Styles;

Also, make sure that you are not trying to invoke FontWeightProperty from System.Windows.Documents.Span but Telerik.Windows.Documents.Model.Span. You can do that by removing the declaration:
using System.Windows.Documents;
or by referencing Span explicitly from the namespace Telerik.Windows.Documents.Model:
StyleDefinition style = this.radRichTextBox.CurrentEditingStyle;
FontWeight weight = (FontWeight)style.GetPropertyValue(Telerik.Windows.Documents.Model.Span.FontWeightProperty);

Let us know if you were able to solve the issue.

Kind regards,
Iva
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
Tags
RichTextBox
Asked by
GEB
Top achievements
Rank 1
Answers by
Paul Dhingra
Top achievements
Rank 1
GEB
Top achievements
Rank 1
Alex
Telerik team
namratha
Top achievements
Rank 2
Iva Toteva
Telerik team
Share this question
or