# Styling Merged Cells

In this article we will discuss the following topics:

* [Targeting the GridViewMergedCell element](https://www.telerik.com/products/wpf/documentation/controls/radgridview/styles-and-templates/styling-mergedcell#targeting-the-gridviewmergedcell-element)

* [Setting MergedCellsStyle](https://www.telerik.com/products/wpf/documentation/controls/radgridview/styles-and-templates/styling-mergedcell#setting-mergedcellsstyle)

* [Setting MergedCellsStyleSelector](https://www.telerik.com/products/wpf/documentation/controls/radgridview/styles-and-templates/styling-mergedcell#setting-mergedcellsstyleselector)

## Targeting the GridViewMergedCell element

In order to style merged cells, you should create an appropriate style targeting the **GridViewMergedCell** element.

You have two options:

* To create an empty style and set it up on your own.

* To copy the default style of the control and modify it.

> To modify the default style, see [Editing Control Templates](https://www.telerik.com/products/wpf/documentation/styling-and-appearance/styling-apperance-editing-control-templates).

> The **GridViewMergedCell** is located in the **Telerik.Windows.Controls.GridView** namespace of the **Telerik.Windows.Controls.GridView** assembly.

> **GridViewMergedCell uses Triggers**, not VisualStateManager's states, to apply property values based on specified conditions.

You can apply a style to the merged cells, similar to:

**Example 1: Styling all merged cells of an application**

```XAML
<Style TargetType="telerik:GridViewMergedCell">
	<Setter Property="VerticalContentAlignment" Value="Top"/>
	<Setter Property="HorizontalContentAlignment" Value="Center"/>
	<Setter Property="Background" Value="#ffcc00"/>
</Style>
```

> If you're using [Implicit Styles](https://www.telerik.com/products/wpf/documentation/styling-and-appearance/styling-apperance-setting-a-theme-overview), you should base your style on the **GridViewMergedCellStyle**.

> caption Styled merged cells

![Telerik UI for WPF RadGridView with a custom style applied to merged cells](https://www.telerik.com/products/wpf/documentation/assets/e26a06b8735654ba76658f04b22a06bf/gridview_merged_cells_5.png)

## Setting MergedCellsStyle

If instead you would like to set a style only for a specific **RadGridView**, you can use its **MergedCellsStyle** property, like so:

**Example 2: Styling merged cells of a specific RadGridView**

```XAML
<Grid.Resources>
	<Style TargetType="telerik:GridViewMergedCell" x:Key="GridViewMergedCellsStyle">
		<Setter Property="VerticalContentAlignment" Value="Top"/>
		<Setter Property="HorizontalContentAlignment" Value="Center"/>
		<Setter Property="Background" Value="#ffcc00"/>
	</Style>
</Grid.Resources>

<telerik:RadGridView MergedCellsStyle="{StaticResource GridViewMergedCellsStyle}" />
```

> tip If you are using [Implicit Themes](https://www.telerik.com/products/wpf/documentation/styling-and-appearance/styling-apperance-setting-a-theme-overview), you should base the style on the one defined for the corresponding theme.

## Setting MergedCellsStyleSelector

You could also use **RadGridView**'s **MergedCellsStyleSelector** property to style merged cells differently based on a specific condition. More details about how this can be achieved can be found in the [MergedCellsStyleSelector article](https://www.telerik.com/products/wpf/documentation/controls/radgridview/style-selectors/merged-cells-style-selector).

## See Also

* [Setting a Theme (Using Implicit Styles)](https://www.telerik.com/products/wpf/documentation/styling-and-appearance/styling-apperance-setting-a-theme-overview)

* [Editing Control Templates](https://www.telerik.com/products/wpf/documentation/styling-and-appearance/styling-apperance-editing-control-templates)

* [Styling a Cell](https://www.telerik.com/products/wpf/documentation/controls/radgridview/styles-and-templates/styling-cell)
