# Highlight Colors Difference Between MS Word and RadRichTextBox

## Environment

<table>
	<tbody>
		<tr>
			<th scope="row">Product Version</th>
			<td>2024.2.514</td>
		</tr>
		<tr>
			<th scope="row">Product</th>
			<td>RadRichTextBox for WPF</td>
		</tr>
	</tbody>
</table>

## Description

The highlight colors that the RadRichTextBox control provides differ from the ones that are present in Microsoft Word. This causes the DOCX format to not use these additional colors when exporting a paragraph.

## Solution

Change the colors of the color picker in the selection mini toolbar of the RadRichTextBox control. To do so, create a custom `SelectionMiniToolBar` and override the `OnApplyTemplate` method. In it, you can customize the colors of the `MainPaletteItemsSource` property of the `HighlightColorPicker` element.

The following example showcases this approach for a **.NET Framework** project. It will utilize the `CustomSelectionMiniToolBar` attribute, which the [MEF support](https://www.telerik.com/products/wpf/documentation/controls/radrichtextbox/mef) will read and use this custom implementation:

**Custom SelectionMiniToolBar for a .NET Framework project**

```C#
    [CustomSelectionMiniToolBar]
    public class CustomSelectionMiniToolBar : SelectionMiniToolBar
    {
        public override void OnApplyTemplate()
        {
            // It is mandatory to call the base OnApplyTemplate.
            base.OnApplyTemplate();

            this.SetHighlightColorPallete();
        }

        private void SetHighlightColorPallete()
        {
            List<Color> colors = new List<Color>
            {
                Colors.Red,
                Colors.Green,
                Colors.Blue
            };

            this.HighlightColorPicker.HeaderPaletteVisibility = System.Windows.Visibility.Hidden;
            this.HighlightColorPicker.StandardPaletteVisibility = System.Windows.Visibility.Hidden;

            this.HighlightColorPicker.MainPaletteItemsSource = colors;

        }
    }
```

The following example showcases this approach for a **.NET** project. Since the MEF functionality is no longer supported by the **.NET 6 and later versions**, set a new instance of the `CustomSelectionMiniToolBar` element to the `SelectionMiniToolBar` property of `RadRichTextBox`.

**Custom SelectionMiniToolBar for a .NET project**

```C#
    //CustomSelectionMiniToolBar attribute is not present
    public class CustomSelectionMiniToolBar : SelectionMiniToolBar
    {
        public override void OnApplyTemplate()
        {
            // It is mandatory to call the base OnApplyTemplate.
            base.OnApplyTemplate();

            this.SetHighlightColorPallete();
        }

        private void SetHighlightColorPallete()
        {
            List<Color> colors = new List<Color>
            {
                Colors.Red,
                Colors.Green,
                Colors.Blue
            };

            this.HighlightColorPicker.HeaderPaletteVisibility = System.Windows.Visibility.Hidden;
            this.HighlightColorPicker.StandardPaletteVisibility = System.Windows.Visibility.Hidden;

            this.HighlightColorPicker.MainPaletteItemsSource = colors;

        }
    }
```

**Setting the custom SelectionMiniToolBar to the RadRichTextBox control**

```C#
	this.richTextBox.SelectionMiniToolBar = new CustomSelectionMiniToolBar(); 
```

> caption RadRichTextBox with a custom SelectionMiniToolBar

![RadRichTextBox with a custom SelectionMiniToolBar](https://www.telerik.com/products/wpf/documentation/assets/acdf30ce0826eea960ad16ce27f138a8/kb-radrichtextbox-difference-in-the-highlighted-colors-0.png)
