# Styles, Resources, and Themes

> Set TextControlColors in XAML and code, style the dependency properties of the WPF TextControl and recolor ResourceProvider icons for your own controls.

- **Product:** TX Text Control .NET for WPF
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Text Control .NET for WPF > Document Editor > Ribbon and UI > Styles, Resources, and Themes
- **2604 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/ribbon-ui/themes/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/ribbon-ui/themes/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/ribbon-ui/themes/llms-full.txt

---

A WPF window gets its look from styles, templates and resources, and the WPF `TextControl` takes part in this: several of its properties are dependency properties that a `Style` can set, its template has named parts, and TX Text Control ships value converters for use as resources. The colors of the editor itself are set through a colors object, and the icons of the ribbon are available as images for your own controls. Read on for each of them in turn.

### Display Colors of the Editor

[DisplayColors](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/displaycolors-property/llms-full.txt) takes a [TextControlColors](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrolcolors/llms-full.txt) object. By default the colors depend on system colors or default values; each property you set replaces one of them, and the properties you leave unset return to their defaults when the object is assigned. The values are `System.Windows.Media.Color` values:

| Property | Color of |
|---|---|
| [DesktopColor](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrolcolors/desktopcolor-property/llms-full.txt) | The area around the pages |
| [PageBackColor](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrolcolors/pagebackcolor-property/llms-full.txt) | The page background |
| [TextColor](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrolcolors/textcolor-property/llms-full.txt), [TextBackColor](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrolcolors/textbackcolor-property/llms-full.txt) | The text and its background |
| [DarkShadowColor](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrolcolors/darkshadowcolor-property/llms-full.txt), [LightShadowColor](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrolcolors/lightshadowcolor-property/llms-full.txt) | The shadows at the right and bottom and at the left and top edges of the pages |
| [HeaderFooterLabelColor](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrolcolors/headerfooterlabelcolor-property/llms-full.txt), [HeaderFooterLineColor](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrolcolors/headerfooterlinecolor-property/llms-full.txt) | The label of an activated header or footer and the line that divides it from the main text |
| [FormFieldColor](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrolcolors/formfieldcolor-property/llms-full.txt), [ActiveFormFieldColor](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrolcolors/activeformfieldcolor-property/llms-full.txt) | The highlighting of form fields and of the form field with the input position; `Transparent` turns it off |

The object can be written directly in XAML, as a property element of the control in *MainWindow.xaml*:

```xml
<WPF:TextControl x:Name="textControl1">
    <WPF:TextControl.DisplayColors>
        <WPF:TextControlColors DesktopColor="#FF404040"
                              PageBackColor="White"
                              FormFieldColor="LightYellow" />
    </WPF:TextControl.DisplayColors>
</WPF:TextControl>
```

The same in code, for example to switch colors while the application runs:

```csharp
using System.Windows.Media;
using TXTextControl.WPF;

TextControlColors colors = new TextControlColors();
colors.DesktopColor = Color.FromRgb(64, 64, 64);
colors.PageBackColor = Colors.White;
textControl1.DisplayColors = colors;
```

The rulers and the status bar have display colors of their own, set through [WPF.RulerBar.DisplayColors](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/rulerbar/displaycolors-property/llms-full.txt) with a [RulerBarColors](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/rulerbar-colors/llms-full.txt) object and through [WPF.StatusBar.DisplayColors](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/statusbar/displaycolors-property/llms-full.txt) with a [StatusBarColors](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/statusbarcolors/llms-full.txt) object. The ruler colors are used only when its `BorderStyle` is `ColorScheme`. [Rulers and Status Bar](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/ribbon-ui/rulers-status-bar/llms-full.txt) covers both bars.

### Set Properties in a Style

Many properties of the `TextControl`, such as `BorderThickness`, `ControlChars` and [ZoomFactor](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/zoomfactor-property/llms-full.txt), are dependency properties, so a `Style` can set them for every `TextControl` in its scope. The following style in the resources of the window shows control characters, removes the border and opens every editor at 120 percent:

```xml
<Window.Resources>
    <Style TargetType="WPF:TextControl">
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="ControlChars" Value="True" />
        <Setter Property="ZoomFactor" Value="120" />
    </Style>
</Window.Resources>
```

[What a Style Can Set](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/integration/styling/#what-a-style-can-set) lists the dependency properties of the `TextControl` and the bars. `DisplayColors` is an ordinary .NET property, so it is set on the control or in code, as shown above.

### The Template of the TextControl

The `TextControl` is a `System.Windows.Controls.Control` with a template of three named parts: a `Border`, a `ScrollViewer` and, inside it, the [TextControlDocument](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontroldocument/llms-full.txt) canvas that shows the document. [What TextControlDocument Is](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/integration/data-binding/textcontroldocument/#what-textcontroldocument-is) lists the parts, and [Get the Part in Code](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/integration/data-binding/textcontroldocument/#get-the-part-in-code) finds one with `Template.FindName` in the `Loaded` event of the control.

### Converters as Resources

TX Text Control provides four value converters, [ColorConverter](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/colorconverter/llms-full.txt), [BooleanConverter](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/booleanconverter/llms-full.txt), [MeasureConverter](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/measureconverter/llms-full.txt) and [LogarithmicConverter](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/logarithmicconverter/llms-full.txt), which are declared as resources and used in bindings to the `TextControl`. [Value Converters](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/integration/data-binding/value-converters/llms-full.txt) declares them and shows an example of each.

Resources also define context menus: the spelling menu that [SpellCheckContextMenu](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/spellcheckcontextmenu-property/llms-full.txt) names is a `ContextMenu` in the resources of the control or a parent, as [Context Menus](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/ribbon-ui/context-menus/llms-full.txt) shows.

### The Ribbon

The ribbon tabs of TX Text Control, such as [RibbonFormattingTab](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/ribbonformattingtab/llms-full.txt), derive from `System.Windows.Controls.Ribbon.RibbonTab`, the tab class of the WPF Ribbon. TX Text Control .NET for WPF has no display colors of its own for the ribbon. [Built-in Ribbon Tabs](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/ribbon-ui/ribbon/llms-full.txt) and [Connecting Ribbon Tabs in XAML](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/ribbon-ui/ribbon-xaml/llms-full.txt) describe how the tabs are placed in a `Ribbon`.

### Icons for Your Own Controls

The static methods of [ResourceProvider](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/resourceprovider/llms-full.txt) return the icons, texts, tooltips and key tips of the built-in ribbon tabs and toolbars, as [Give Your Buttons the Built-in Icons](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/ribbon-ui/custom-tabs/#give-your-buttons-the-built-in-icons) lists. For the icons, an [ImageSourceSettings](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/resourceprovider-imagesourcesettings/llms-full.txt) object recolors the color rectangle of icons such as `TXITEM_TextColor` with [FillColor](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/resourceprovider-imagesourcesettings/fillcolor-property/llms-full.txt) and [StrokeColor](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/resourceprovider-imagesourcesettings/strokecolor-property/llms-full.txt), and picks language-specific icons with [Culture](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/resourceprovider-imagesourcesettings/culture-property/llms-full.txt).

The following code shows the text color icon with a red rectangle in an `Image` named `textColorImage`:

```csharp
private void TextControl1_Loaded(object sender, RoutedEventArgs e)
{
    ResourceProvider.ImageSourceSettings settings = new ResourceProvider.ImageSourceSettings();
    settings.FillColor = Colors.Red;

    // Create the icon in the resolution of the window
    textColorImage.Source = ResourceProvider.GetSmallIcon("TXITEM_TextColor", this, settings);
}
```

It needs `using System.Windows.Media;` for `Colors` and `using TXTextControl.WPF;` for `ResourceProvider`, and an element such as `<Image x:Name="textColorImage" Width="16" Height="16" />` in the window.

### Next Steps

- [Custom Tabs and Commands](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/ribbon-ui/custom-tabs/llms-full.txt): ribbon items with the icons of TX Text Control.
- [Rulers and Status Bar](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/ribbon-ui/rulers-status-bar/llms-full.txt): the colors of the rulers and the status bar.
- [Localization and Resource Kit](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/ribbon-ui/localization/llms-full.txt): texts and icons in other languages.
- [Right-to-Left UI](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/ribbon-ui/right-to-left/llms-full.txt): the flow direction of the window.

---

## Nearby

- **Previous:** [Built-In Dialog Boxes](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/ribbon-ui/dialog-boxes/llms-full.txt)
- **Next:** [Localization and Resource Kit](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/ribbon-ui/localization/llms-full.txt)
