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
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'.
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.
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
thanks in advance
regards
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;
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