Reusable Ribbon Tab for RTB

3 posts, 0 answers
  1. Greg Gum
    Greg Gum avatar
    18 posts
    Member since:
    Jun 2009

    Posted 04 Jan 2012 Link to this post

    I have an application which has several different pages.  Each page has it's own custom Ribbon View.  Each page also has a RichTextBox for storing notes which needs a Ribbon Tab for formatting, which is added to the custom Ribbon.

    So, what I did was take code from a sample that has the usual cut/copy/paste formatting etc, and drop it into a RibbonTab for a page.  This works fine.

    However, I have many many pages, and I would like to create a reusable element so I can just drop it into a RibbonView and it will show the Formatting Tab.  I did this by creating a UserControl which has a base class of RibbonTab and includes the formatting commands.  This shows up as expected in the custom RibbonView.  However, it loses it's link to the RTB on the page, so the commands no longer function on the RTB, and I am not sure how to wire these back up.

    Here is a snippit.  If I pull the xaml out of the NotexContextTab and replace the first line below, it does connect up just fine.  But with the RibbonUI in it's own file, the binding is lost.
    <local:NotesContextTab DataContext="{Binding ElementName=rtbNotes}" />
           <telerik:RadRichTextBox x:Name="rtbNotes" >

    The NotesContextTab file looks like this.  In the below, I based it off the full RadRichTextBoxRibbonUI to try to make it connect, but all I really wanted was one tab to drop into another existing ribbon view.

    <telerik:RadRichTextBoxRibbonUI x:Class="RibbonBarTest.NotesContextTab"
                                    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                                    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                                    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                                    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                                    xmlns:telerikRibbonView="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.RibbonView"
                                    mc:Ignorable="d">
        <telerikRibbonView:RadRibbonTab>
     
     
            <telerikRibbonView:RadRibbonTab.Resources>
                <telerik:FontFamiliesProvider x:Key="FontFamiliesProvider" />
            </telerikRibbonView:RadRibbonTab.Resources>
            <telerikRibbonView:RadRibbonGroup Header="Clipboard">
                <telerikRibbonView:RadRibbonGroup.Variants>
                    <telerikRibbonView:GroupVariant Priority="0"
                                                    Variant="Medium" />
                </telerikRibbonView:RadRibbonGroup.Variants>
                <StackPanel>
                    <telerikRibbonView:RadRibbonButton CollapseToSmall="WhenGroupIsMedium"
                                                       telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=CutCommand}"
                                                       telerikRibbonView:ScreenTip.Description="Cut the selection and put it on the Clipboard."
                                                       telerikRibbonView:ScreenTip.Title="Cut"
                                                       Size="Medium"
                                                       SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/cut.png"
                                                       Text="Cut" />
                    <telerikRibbonView:RadRibbonButton CollapseToSmall="WhenGroupIsMedium"
                                                       telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=CopyCommand}"
                                                       telerikRibbonView:ScreenTip.Description="Copy the selection and put it on the Clipboard."
                                                       telerikRibbonView:ScreenTip.Title="Copy"
                                                       Size="Medium"
                                                       SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/copy.png"
                                                       Text="Copy" />
                    <telerikRibbonView:RadRibbonButton CollapseToSmall="WhenGroupIsMedium"
                                                       telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=PasteCommand}"
                                                       telerikRibbonView:ScreenTip.Description="Paste the contents of the Clipboard."
                                                       telerikRibbonView:ScreenTip.Title="Paste"
                                                       Size="Medium"
                                                       SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/paste.png"
                                                       Text="Paste" />
                </StackPanel>
            </telerikRibbonView:RadRibbonGroup>
            <telerikRibbonView:RadRibbonGroup DialogLauncherVisibility="Visible"
                                              Header="Font"
                                              telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ShowFontPropertiesDialogCommand}"
                                              telerik:ScreenTip.Description="Show the font dialog box."
                                              telerik:ScreenTip.Title="Font"
                                              telerik:ScreenTip.Icon="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/FontDialog.png">
                <telerikRibbonView:RadRibbonGroup.Variants>
                    <telerikRibbonView:GroupVariant Priority="4"
                                                    Variant="Medium" />
                    <telerikRibbonView:GroupVariant Priority="6"
                                                    Variant="Small" />
                    <telerikRibbonView:GroupVariant Priority="7"
                                                    Variant="Collapsed" />
                </telerikRibbonView:RadRibbonGroup.Variants>
                <telerikRibbonView:RadOrderedWrapPanel>
                    <StackPanel Orientation="Horizontal">
                        <telerikRibbonView:RadRibbonComboBox CanAutocompleteSelectItems="False"
                                                             CanKeyboardNavigationSelectItems="False"
                                                             CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=SelectedValue}"
                                                             Height="21"
                                                             IsReadOnly="True"
                                                             ItemsSource="{Binding Source={StaticResource FontFamiliesProvider}, Path=RegisteredFonts}"
                                                             OpenDropDownOnFocus="True"
                                                             telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ChangeFontFamilyCommand}"
                                                             telerikRibbonView:ScreenTip.Description="Change the font family."
                                                             telerikRibbonView:ScreenTip.Title="Font"
                                                             Width="132" />
                        <telerikRibbonView:RadRibbonComboBox CanAutocompleteSelectItems="False"
                                                             CanKeyboardNavigationSelectItems="False"
                                                             CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=SelectedItem.Tag}"
                                                             Height="21"
                                                             IsEditable="True"
                                                             IsReadOnly="True"
                                                             IsTextSearchEnabled="False"
                                                             OpenDropDownOnFocus="True"
                                                             telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ChangeFontSizeCommand}"
                                                             telerikRibbonView:ScreenTip.Description="Change the font size."
                                                             telerikRibbonView:ScreenTip.Title="Font Size"
                                                             Width="45">
                            <telerikRibbonView:RadRibbonComboBoxItem Content="8"
                                                                     Tag="10.67" />
                            <telerikRibbonView:RadRibbonComboBoxItem Content="9"
                                                                     Tag="12" />
                            <telerikRibbonView:RadRibbonComboBoxItem Content="10"
                                                                     Tag="13.33" />
                            <telerikRibbonView:RadRibbonComboBoxItem Content="11"
                                                                     Tag="14.67" />
                            <telerikRibbonView:RadRibbonComboBoxItem Content="12"
                                                                     Tag="16" />
                            <telerikRibbonView:RadRibbonComboBoxItem Content="14"
                                                                     Tag="18.67" />
                            <telerikRibbonView:RadRibbonComboBoxItem Content="16"
                                                                     Tag="21.33" />
                            <telerikRibbonView:RadRibbonComboBoxItem Content="18"
                                                                     Tag="24" />
                            <telerikRibbonView:RadRibbonComboBoxItem Content="20"
                                                                     Tag="26.67" />
                            <telerikRibbonView:RadRibbonComboBoxItem Content="22"
                                                                     Tag="29.33" />
                            <telerikRibbonView:RadRibbonComboBoxItem Content="24"
                                                                     Tag="32" />
                            <telerikRibbonView:RadRibbonComboBoxItem Content="26"
                                                                     Tag="34.67" />
                            <telerikRibbonView:RadRibbonComboBoxItem Content="28"
                                                                     Tag="37.33" />
                            <telerikRibbonView:RadRibbonComboBoxItem Content="36"
                                                                     Tag="48" />
                            <telerikRibbonView:RadRibbonComboBoxItem Content="48"
                                                                     Tag="64" />
                            <telerikRibbonView:RadRibbonComboBoxItem Content="72"
                                                                     Tag="96" />
                        </telerikRibbonView:RadRibbonComboBox>
                    </StackPanel>
                    <telerikRibbonView:RadButtonGroup>
                        <telerikRibbonView:RadRibbonButton telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=IncrementFontSizeCommand}"
                                                           telerikRibbonView:ScreenTip.Description="Increase the font size."
                                                           telerikRibbonView:ScreenTip.Title="Grow Font"
                                                           Size="Small"
                                                           SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/font-increasesize.png" />
                        <telerikRibbonView:RadRibbonButton telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=DecrementFontSizeCommand}"
                                                           telerikRibbonView:ScreenTip.Description="Decrease the font size."
                                                           telerikRibbonView:ScreenTip.Title="Shrink Font"
                                                           Size="Small"
                                                           SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/font-decreasesize.png" />
                    </telerikRibbonView:RadButtonGroup>
                    <telerikRibbonView:RadButtonGroup>
                        <telerikRibbonView:RadRibbonButton telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ClearFormattingCommand}"
                                                           telerikRibbonView:ScreenTip.Description="Clear all the formatting from the selection, leaving only the plain text."
                                                           telerikRibbonView:ScreenTip.Title="Clear Formatting"
                                                           Size="Small"
                                                           SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/ClearFormatting16.png" />
                    </telerikRibbonView:RadButtonGroup>
                    <telerikRibbonView:RadButtonGroup>
                        <telerikRibbonView:RadRibbonToggleButton telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ToggleBoldCommand}"
                                                                 telerikRibbonView:ScreenTip.Description="Make the selected text bold."
                                                                 telerikRibbonView:ScreenTip.Title="Bold"
                                                                 Size="Small"
                                                                 SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/bold.png" />
                        <telerikRibbonView:RadRibbonToggleButton telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ToggleItalicCommand}"
                                                                 telerikRibbonView:ScreenTip.Description="Italicize the selected text."
                                                                 telerikRibbonView:ScreenTip.Title="Italic"
                                                                 Size="Small"
                                                                 SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/italic.png" />
                        <telerikRibbonView:RadRibbonSplitButton IsToggle="True"
                                                                telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ToggleUnderlineCommand}"
                                                                telerikRibbonView:ScreenTip.Description="Underline the selected text."
                                                                telerikRibbonView:ScreenTip.Title="Underline"
                                                                SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/underline.png">
                            <telerikRibbonView:RadRibbonSplitButton.DropDownContent>
                                <telerik:RadGallery ItemHeight="26"
                                                    ItemWidth="156"
                                                    telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ChangeUnderlineDecorationCommand}"
                                                    ViewportHeight="210"
                                                    ViewportWidth="157">
                                    <telerikRibbonView:RadGalleryItem Image="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/underline1.png"
                                                                      Tag="Line" />
                                    <telerikRibbonView:RadGalleryItem Image="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/underline2.png"
                                                                      Tag="DoubleLine" />
                                    <telerikRibbonView:RadGalleryItem Image="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/underline3.png"
                                                                      Tag="ThickLine" />
                                    <telerikRibbonView:RadGalleryItem Image="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/underline4.png"
                                                                      Tag="DottedLine" />
                                    <telerikRibbonView:RadGalleryItem Image="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/underline5.png"
                                                                      Tag="DashedLine" />
                                    <telerikRibbonView:RadGalleryItem Image="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/underline6.png"
                                                                      Tag="DotDashedLine" />
                                    <telerikRibbonView:RadGalleryItem Image="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/underline7.png"
                                                                      Tag="DotDotDashedLine" />
                                    <telerikRibbonView:RadGalleryItem Image="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/underline8.png"
                                                                      Tag="Wave" />
                                </telerik:RadGallery>
                            </telerikRibbonView:RadRibbonSplitButton.DropDownContent>
                        </telerikRibbonView:RadRibbonSplitButton>
                        <telerikRibbonView:RadRibbonToggleButton telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ToggleStrikethroughCommand}"
                                                                 telerikRibbonView:ScreenTip.Description="Draw a line through the middle of the selected text."
                                                                 telerikRibbonView:ScreenTip.Title="Strikethrough"
                                                                 Size="Small"
                                                                 SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/Strikethrough16.png" />
                        <telerikRibbonView:RadRibbonToggleButton telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ToggleSubscriptCommand}"
                                                                 telerikRibbonView:ScreenTip.Description="Create small letters below the text baseline."
                                                                 telerikRibbonView:ScreenTip.Title="Subscript"
                                                                 Size="Small"
                                                                 SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/subscript.png" />
                        <telerikRibbonView:RadRibbonToggleButton telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ToggleSuperscriptCommand}"
                                                                 telerikRibbonView:ScreenTip.Description="Create small text above the line of text."
                                                                 telerikRibbonView:ScreenTip.Title="Superscript"
                                                                 Size="Small"
                                                                 SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/superscript.png" />
                    </telerikRibbonView:RadButtonGroup>
                    <telerikRibbonView:RadButtonGroup>
                        <telerik:HighlightColorPicker AutomaticColor="Transparent"
                                                      Height="22"
                                                      Image="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/highlight.png"
                                                      NoColorText="No color"
                                                      telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ChangeFontHighlightColorCommand}"
                                                      telerikRibbonView:ScreenTip.Description="Make text look like it was marked with a highlighter pen."
                                                      telerikRibbonView:ScreenTip.Title="Text Highlight Color"
                                                      SelectedColor="Yellow" />
                        <telerik:HighlightColorPicker Height="22"
                                                      Image="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/FontForeColor.png"
                                                      telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ChangeFontForeColorCommand}"
                                                      telerikRibbonView:ScreenTip.Description="Change the text color."
                                                      telerikRibbonView:ScreenTip.Title="Font Color"
                                                      SelectedColor="Red" />
                    </telerikRibbonView:RadButtonGroup>
                </telerikRibbonView:RadOrderedWrapPanel>
            </telerikRibbonView:RadRibbonGroup>
            <telerikRibbonView:RadRibbonGroup DialogLauncherVisibility="Visible"
                                              Header="Paragraph"
                                              telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ShowParagraphPropertiesDialogCommand}"
                                              telerikRibbonView:ScreenTip.Description="Show the Paragraph dialog box."
                                              telerikRibbonView:ScreenTip.Title="Paragraph"
                                              telerikRibbonView:ScreenTip.Icon="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/PropertiesDialog.png">
                <telerikRibbonView:RadRibbonGroup.Variants>
                    <telerikRibbonView:GroupVariant Priority="3"
                                                    Variant="Medium" />
                    <telerikRibbonView:GroupVariant Priority="5"
                                                    Variant="Collapsed" />
                </telerikRibbonView:RadRibbonGroup.Variants>
                <telerikRibbonView:RadOrderedWrapPanel>
                    <telerikRibbonView:RadButtonGroup>
                        <telerikRibbonView:RadRibbonToggleButton telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ToggleBulletsCommand}"
                                                                 telerikRibbonView:ScreenTip.Description="Start a bulleted list."
                                                                 telerikRibbonView:ScreenTip.Title="Bullets"
                                                                 Size="Small"
                                                                 SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/list-bullets.png" />
                        <telerikRibbonView:RadRibbonToggleButton telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ToggleNumberedCommand}"
                                                                 telerikRibbonView:ScreenTip.Description="Start a numbered list."
                                                                 telerikRibbonView:ScreenTip.Title="Numbering"
                                                                 Size="Small"
                                                                 SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/list-numbered.png" />
                        <telerikRibbonView:RadRibbonDropDownButton telerikRibbonView:ScreenTip.Description="Start a multilevel list. &#x0a;&#x0a;Click the arrow to choose different multilevel list styles."
                                                                   telerikRibbonView:ScreenTip.Title="Multilevel List"
                                                                   Size="Small"
                                                                   SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/MultilevelList.png">
                            <telerikRibbonView:RadRibbonDropDownButton.DropDownContent>
                                <StackPanel>
                                    <telerikRibbonView:RadGroupHeader Content="List Library" />
                                    <telerikRibbonView:RadGallery ItemHeight="88"
                                                                  ItemWidth="88"
                                                                  telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ChangeListStyleCommand}"
                                                                  ViewportHeight="176"
                                                                  ViewportWidth="266">
                                        <telerikRibbonView:RadGalleryItem Image="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/MultilevelListNone.png"
                                                                          Tag="None" />
                                        <telerikRibbonView:RadGalleryItem Image="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/MultilevelListBulleted.png"
                                                                          Tag="Bulleted" />
                                        <telerikRibbonView:RadGalleryItem Image="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/MultilevelListNumbered.png"
                                                                          Tag="Numbered" />
                                        <telerikRibbonView:RadGalleryItem Image="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/MultilevelListNumberedParenthesis.png"
                                                                          Tag="NumberedParenthesis" />
                                        <telerikRibbonView:RadGalleryItem Image="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/MultilevelListNumberedHierarchical.png"
                                                                          Tag="NumberedHierarchical" />
                                    </telerikRibbonView:RadGallery>
                                </StackPanel>
                            </telerikRibbonView:RadRibbonDropDownButton.DropDownContent>
                        </telerikRibbonView:RadRibbonDropDownButton>
                    </telerikRibbonView:RadButtonGroup>
                    <telerikRibbonView:RadButtonGroup>
                        <telerikRibbonView:RadRibbonButton telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=DecrementParagraphLeftIndentCommand}"
                                                           telerikRibbonView:ScreenTip.Description="Decrease the indent level of the paragraph."
                                                           telerikRibbonView:ScreenTip.Title="Decrease Indent"
                                                           Size="Small"
                                                           SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/outdent.png" />
                        <telerikRibbonView:RadRibbonButton telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=IncrementParagraphLeftIndentCommand}"
                                                           telerikRibbonView:ScreenTip.Description="Increase the indent level of the paragraph."
                                                           telerikRibbonView:ScreenTip.Title="Increase Indent"
                                                           Size="Small"
                                                           SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/indent.png" />
                    </telerikRibbonView:RadButtonGroup>
                    <telerikRibbonView:RadButtonGroup>
                        <telerikRibbonView:RadRibbonToggleButton CommandParameter="LeftToRight"
                                                                 telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ChangeParagraphFlowDirectionCommand}"
                                                                 telerikRibbonView:ScreenTip.Description="Set the direction of text to be displayed from left to right."
                                                                 telerikRibbonView:ScreenTip.Title="Left-To-Right Text Direction"
                                                                 Size="Small"
                                                                 SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/LeftToRightFlowDirection.png"
                                                                 Text="Left-to-Right Text Direction" />
                        <telerikRibbonView:RadRibbonToggleButton CommandParameter="RightToLeft"
                                                                 telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ChangeParagraphFlowDirectionCommand}"
                                                                 telerikRibbonView:ScreenTip.Description="Set the direction of text to be displayed from right to left."
                                                                 telerikRibbonView:ScreenTip.Title="Right-To-Left Text Direction"
                                                                 Size="Small"
                                                                 SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/RightToLeftFlowDirection.png"
                                                                 Text="Right-to-Left Text Direction" />
                    </telerikRibbonView:RadButtonGroup>
                    <telerikRibbonView:RadButtonGroup>
                        <telerikRibbonView:RadRibbonToggleButton telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ToggleFormattingSymbolsCommand}"
                                                                 telerikRibbonView:ScreenTip.Description="Show paragraph marks and other hidden formatting symbols."
                                                                 telerikRibbonView:ScreenTip.Title="Show/Hide Formatting Symbols"
                                                                 Size="Small"
                                                                 SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/formatting-symbols.png" />
                    </telerikRibbonView:RadButtonGroup>
                    <telerikRibbonView:RadButtonGroup>
                        <telerikRibbonView:RadRibbonToggleButton CommandParameter="Left"
                                                                 telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ChangeTextAlignmentCommand}"
                                                                 telerikRibbonView:ScreenTip.Description="Align text to the left."
                                                                 telerikRibbonView:ScreenTip.Title="Align Text Left"
                                                                 Size="Small"
                                                                 SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/alignleft.png"
                                                                 Text="Align Left" />
                        <telerikRibbonView:RadRibbonToggleButton CommandParameter="Center"
                                                                 telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ChangeTextAlignmentCommand}"
                                                                 telerikRibbonView:ScreenTip.Description="Center text."
                                                                 telerikRibbonView:ScreenTip.Title="Center"
                                                                 Size="Small"
                                                                 SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/aligncenter.png"
                                                                 Text="Center" />
                        <telerikRibbonView:RadRibbonToggleButton CommandParameter="Right"
                                                                 telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ChangeTextAlignmentCommand}"
                                                                 telerikRibbonView:ScreenTip.Description="Align text to the right."
                                                                 telerikRibbonView:ScreenTip.Title="Align Text Right"
                                                                 Size="Small"
                                                                 SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/alignright.png"
                                                                 Text="Align Right" />
                        <telerikRibbonView:RadRibbonToggleButton CommandParameter="Justify"
                                                                 telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ChangeTextAlignmentCommand}"
                                                                 telerikRibbonView:ScreenTip.Description="Align text to both left and right margins, adding extra space between words as necessary."
                                                                 telerikRibbonView:ScreenTip.Title="Justify"
                                                                 Size="Small"
                                                                 SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/alignjustify.png"
                                                                 Text="Justify" />
                    </telerikRibbonView:RadButtonGroup>
                    <telerikRibbonView:RadButtonGroup>
                        <telerik:HighlightColorPicker AutomaticColor="Transparent"
                                                      Height="20"
                                                      Image="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/ParagraphBackgroundColor.png"
                                                      NoColorText="No color"
                                                      telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ChangeParagraphBackgroundColorCommand}"
                                                      telerikRibbonView:ScreenTip.Description="Color the background behind the selected text or paragraph."
                                                      telerikRibbonView:ScreenTip.Title="Shading"
                                                      SelectedColor="Transparent" />
                    </telerikRibbonView:RadButtonGroup>
                </telerikRibbonView:RadOrderedWrapPanel>
            </telerikRibbonView:RadRibbonGroup>
        </telerikRibbonView:RadRibbonTab>
    </telerik:RadRichTextBoxRibbonUI>



    Thanks,

    Greg

  2. Boby
    Admin
    Boby avatar
    595 posts

    Posted 09 Jan 2012 Link to this post

    Hello Greg,
    If I understand you right, you have to set the data context of your custom control to Commands property of RadRichTextBox:
    <local:NotesContextTab DataContext="{Binding ElementName=rtbNotes, Path=Commands}" />
           <telerik:RadRichTextBox x:Name="rtbNotes" >

    Don't hesitate to contact us if you have other questions or need further assistance.


    All the best,
    Boby
    the Telerik team

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

  3. DevCraft banner
  4. Greg Gum
    Greg Gum avatar
    18 posts
    Member since:
    Jun 2009

    Posted 09 Jan 2012 Link to this post

    Great, thanks.

    Greg
Back to Top