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

RadRibbonToggleButtons and RadRibbonButtons in a RadToolbar?

1 Answer 151 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 20 Dec 2010, 07:12 PM
I'm currently using the Radrichtextbox for very simple text input.  I don't need to many bells and whistles, I just need a few of the formatting buttons, spell check, find, cut, copy, and paste.  I previously was using the RadRichTextBoxRibbonUI, but I found I was cutting out most of it, and manipulating it to hide parts, just to get it to look like the radtoolbar.  So, I replaced it with the radtoolbar.  However, I still want the functionality of the RadRichTextBoxRibbonUI.  So, I'm using RadRibbonTobbleButtons inside of the RadToolbar.  Here is my code:

<telerikNavigation:RadToolBar DataContext="{Binding Path=Commands, ElementName=_rrtbMessage}"
                             Height="35"
                             HorizontalAlignment="Stretch"
                             Margin="10,0,10,0"
                             x:Name="_toolBar"
                             VerticalAlignment="Top"
                             Width="Auto"
                             OverflowButtonVisibility="Collapsed">
            <telerik:RadRibbonToggleButton x:Name="_boldBtn"
                                           RichTextBoxUI:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ToggleBoldCommand}"
                                           SmallImage="/Images/Bold T.png"
                                           Margin="0,0,0,5"
                                           VerticalAlignment="Center"
                                           ToolTipService.ToolTip="Bold">
            </telerik:RadRibbonToggleButton>
            <telerik:RadRibbonToggleButton x:Name="_italicBtn"
                                           RichTextBoxUI:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ToggleItalicCommand}"
                                           SmallImage="/Images/Italic T.png"
                                           Margin="0,0,0,5"
                                           VerticalAlignment="Center"
                                           ToolTipService.ToolTip="Italic">
            </telerik:RadRibbonToggleButton>
            <telerik:RadRibbonToggleButton x:Name="_underlineBtn"
                                           RichTextBoxUI:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ToggleUnderlineCommand}"
                                           SmallImage="/Images/Underline T.png" 
                                           Margin="0,0,0,5"
                                           VerticalAlignment="Center"
                                           ToolTipService.ToolTip="Underline">
            </telerik:RadRibbonToggleButton>
</telerikNavigation:RadToolBar>

It works fine, but it seems a little out of place to have ribbonbuttons used in the toolbar.  Is there a better way to do this?
Thanks,
Michael

1 Answer, 1 is accepted

Sort by
0
Accepted
Boby
Telerik team
answered on 22 Dec 2010, 09:34 AM
Hi Michael,
Currently RadRichTextBoxRibbonUI.RichTextCommand attached property works only with RadRibbonToggleButtons. If you want to use standard ToggleButtons, you have to manually subscribe to events that our commands expose and update button state in the event handler (this is what we do behind the scenes in the attached property).
Here is the sample XAML:
<telerik:RadRichTextBox Grid.Row="1" Name="radRichTextBox1" />
        <telerik:RadToggleButton Content="Button" Name="buttonBold" Command="{Binding ElementName=radRichTextBox1, Path=Commands.ToggleBoldCommand}"/>  
and the sample code behind:
public MainPage()
{
    InitializeComponent();
  
    this.radRichTextBox1.Commands.ToggleBoldCommand.ToggleStateChanged += (s, a) => { this.buttonBold.IsChecked = e.NewValue; };
}

Don't hesitate to contact us if you have other questions.


Best wishes,
Boby
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
Tags
RichTextBox
Asked by
Michael
Top achievements
Rank 1
Answers by
Boby
Telerik team
Share this question
or