This project has moved and is read-only. For the latest updates, please go here.

Customising the RichTextBoxFormatBar

Feb 21, 2014 at 5:14 PM
Hi all. Dos anyone have any idea of how to customise the RichTextBoxFormatBar by creating a custom class implementing the IRichTextBoxFormatBar interface?

I don't want to add to the control, just want to take some elements away ie Colour selection, underline.

Feb 21, 2014 at 8:51 PM

You will have to re-style the RichTextFormatBar by giving it a new ControlTemplate. You can fin the original ControlTemplate in :
-Xceed.Wpf.Toolkit/RichTextFormatBar/Aero2.NormalColor.xaml (windows8)
-Xceed.Wpf.Toolkit/RichTextFormatBar/Generic.xaml (windows7)
under the name : "richTextBoxFormatBarTemplate"
Feb 24, 2014 at 9:34 AM
Great thanks. Where can I find these XAML files?
Feb 24, 2014 at 1:27 PM

The SourceCode files are available on CodePLex :
Feb 24, 2014 at 3:42 PM
Thank you, is it normal procedure to create a new custom Control or does this XAML sit in a resource dictionary?

Sorry, new to WPF.
Feb 25, 2014 at 1:13 PM

The current RichTextBoxFormatBar has a default design in a resource Dictionary in the Toolkit. If you want to have a new Design, you have to modify the current control in XAML. Usually, properties lets user modify the behavior of a control, but if special changes needs to be done (like modifying the design), the ControlTemplate of the controls needs to be redone.
Feb 25, 2014 at 2:55 PM
Thanks. I have created a Custom Control, used the xaml source code in Themes/Generic.xaml and created the necessary .cs files from the source code. IsesFormatBar.cs is the control file which inherits from Control.

Here is my Generic.xaml:

    <conv:ColorToSolidColorBrushConverter x:Key="ColorToSolidColorBrushConverter" />

    <ControlTemplate TargetType="{x:Type MyNamespace:IsesFormatBar}" x:Key="IsesFormatTemplate">
        <Border Background="Transparent"
              ToolTip="Click to Drag">
            <StackPanel VerticalAlignment="Center"
                <Line SnapsToDevicePixels="True"
etc etc



    <!-- =================================================================== -->
    <!-- Style                                                               -->
    <!-- =================================================================== -->
    <Style TargetType="{x:Type MyNamespace:IsesFormatBar}">
        <Setter Property="Template"
              Value="{StaticResource richTextBoxFormatBarTemplate}" />
        <Setter Property="Effect">
                <DropShadowEffect BlurRadius="5"
                              Opacity=".25" />
        <Setter Property="Background"
              Value="Transparent" />
        <Setter Property="IsTabStop"
              Value="false" />
I cannot view the tool design in the designer of Generic.xaml, I am getting the message 'Intentionally Left Blank. The document root element is not supported by the visual designer'.

Any ideas?
Feb 25, 2014 at 6:57 PM
from what I see, you create a style for objects of type MyNamespace:IsesFormatBar which uses the ControlTemplate "richTextBoxFormatBarTemplate". On the other hand, there is a ControlTemplate (for MyNamespace:IsesFormatBar objects type ), named "IsesFormatTemplate", which is not used.