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

RadRichTextBoxRibbonUI not changing font style and size on RibbonBar

7 Answers 253 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
GEB
Top achievements
Rank 1
GEB asked on 27 Jul 2010, 08:11 PM
Using the new RadRichTextBoxRibbonUI, when the user clicks on an existing run of text, the RibbonBar does not change to reflect the font stype and size of that text.  For example, insert some new text that is Arial Font, Size 24.  Anytime you return the caret to this text, the RiblonBar will remain at the current text style and size, and will not reflect the size and style (Arial/24) of the text selected.

I'm using the Q2 release of RadControls.

7 Answers, 1 is accepted

Sort by
0
Stephen
Top achievements
Rank 1
answered on 28 Jul 2010, 12:54 AM
Hi GEB,

Telerik answered this question for me in this thread.

To give a specific example.  Lets take the FontFamily one.

I use this code to listen to events from the ChangeFontFamilyCommand:

this.TextArea.ChangeFontFamilyCommand.FontFamilyChanged += (sender, e) =>
            {
                if(this.FontFamilyComboBox.Items.Count > 0)
                {
                    // Get the newly selected item
                    RadRibbonComboBoxItem item = (from comboItem in this.FontFamilyComboBox.Items.Cast<RadRibbonComboBoxItem>()
                                                  where comboItem.FontFamily.Source == e.NewValue.Source
                                                  select comboItem).First();
  
                    this.FontFamilyComboBox.SelectedItem = item;
                }
                  
            };


Where TextArea is the name of my RadRichTextBox and FontFamilyComboBox is the name of my combobox control used to manage fonts.

This is the XAML for the ComboBox.

<telerik:RadRibbonComboBox x:Name="FontFamilyComboBox"
                                                           telerik:ScreenTip.Title="Font" telerik:ScreenTip.Description="Change the font face." Command="{Binding ChangeFontFamilyCommand}"
                                                           CommandParameter="{Binding SelectedItem, RelativeSource={RelativeSource Self}}">
                                    <telerik:RadRibbonComboBoxItem Content="Arial" FontFamily="Arial" Tag="Arial" />
                                    <telerik:RadRibbonComboBoxItem Content="Century Gothic" FontFamily="Century Gothic" Tag="Century Gothic" />
<!-- More fonts can appear here -->
                                </telerik:RadRibbonComboBox>

You can re-use this pattern across the other commands on the RadRichTextBox.

Hope this helps,

Stephen
0
GEB
Top achievements
Rank 1
answered on 28 Jul 2010, 05:37 AM
Stephen, thanks for your response.  I would think that these events would be handled completely by the new RadRichTextBoxRibbonUI, and not have to be handled by my code-behind.
0
Stephen
Top achievements
Rank 1
answered on 28 Jul 2010, 05:37 AM
I've just been playing with this myself as its reminded me of a bug in our own UI.

The problem is when the control first loads content from an external source the initial settings won't come across to the editor controls.  For example if I have two paragraphs, the first one is Comic Sans MS, and the second one is Arial.  At this point the control would not have loaded and so the event to update the drop down will not have fired.  How do I get the current style settings for the initially selected caret?

Stephen
0
Stephen
Top achievements
Rank 1
answered on 28 Jul 2010, 05:40 AM
Oh,  I was under the impression that you were creating your own UI as I am. 

I think they should be, at least if you look at the thread I refered to Bobby has stated it should happen automagically, are you getting all the autogenerated XAML?
0
Boby
Telerik team
answered on 28 Jul 2010, 03:45 PM
Hello GEB,
RadRichTextBoxRibbonUI handles events of its associated RadRichTextBox and updates itself automatically. For this to happen, auto generated controls in RadRichTextBoxRibbonUI are bound to commands of RadRichTextBox. If I follow your example with Font ComboBox, it is wired with the auto generated code like following:
<telerik:RadRibbonComboBox CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=SelectedItem}" telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ChangeFontFamilyCommand}"...
For these bindings to work, the DataContext of RadRichTextBoxRibbonUI must be set too:
<telerik:RadRichTextBoxRibbonUI DataContext="{Binding ElementName=radRichTextBox1}" ...
where radRichTextBox1 is the name of associated RadRichTextBox. If the previous code is present, RadRichTextBoxRibbonUI should update itself according to radRichTextBox1.

All the above XAML is auto generated from the RadRichTextBoxRibbonUI, but I list it here in case you accidentally delete some required parts of it, while editing it manually.

Greetings,
Boby
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 28 Jul 2010, 04:51 PM
Thanks for your reply Boby.  I am using RadRichTextBox and RadRichTextBoxRibbonUI unchanged from the Q2 version.  It all seems to be working quite well except that I have found several issues which are exhibited in a small sample application I have developed.  Perhaps it would be best to document each of these issues, package up the sample application and open a support ticket.
0
Boby
Telerik team
answered on 29 Jul 2010, 04:57 PM
Hi GEB,

We will be glad to hear about these issues. Any feedback will be highly appreciated.

Kind regards,
Boby
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
Stephen
Top achievements
Rank 1
GEB
Top achievements
Rank 1
Boby
Telerik team
Share this question
or