# Styling and Style Selectors

This topic describes the properties you can use to customize the default look-and-feel of the **RadDiagram** items.

The **RadDiagram** exposes the following **Style** properties to allow you to easily customize its **Shapes, Connections, Connectors** as well as the default selection and grouping rectangles.

* **ShapeStyle** - applies a **Style** on all **RadDiagramsShapes** defined in the **RadDiagram**. Further information about the **RadDiagramShape** you can find [here](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/diagram-items/shape/raddiagrams-features-shapes).

* **ShapeStyleSelector** - defines a **StyleSelector**, which can be used to apply different **Styles** on different **RadDiagramShape** instances inside the **RadDiagram**.

* **ContainerShapeStyle** - applies a **Style** on all **RadDiagramContainerShape** objects defined in the **RadDiagram** instance. Further information about the **RadDiagramContainerShape** you can find [here](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/diagram-items/features-container-shapes).

* **ConnectionStyle** - applies a **Style** on all **RadDiagramsConnections** defined in the **RadDiagram**. Further information about the **RadDiagramConnection** you can find [here](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/diagram-items/raddiagrams-features-connections).

* **ConnectionStyleSelector** - defines a **StyleSelector**, which can be used to apply different **Styles** on different **RadDiagramsConnection** instances inside the **RadDiagram**.

* **ConnectorStyle** - this property gives you the ability to apply a customized style on all **RadDiagramConnectors** inside the **RadDiagram**. Further information about the **RadDiagramConnector** you can find [here](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/features/custom-connectors).

* **GroupStyle** - this property allows you to create a custom style targeting the **Rectangle** object that visualizes the **RadDiagramItems** grouping. This **RadDiagram** feature is described in more details [here](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/features/grouping).

* **SelectionRectangleStyle** - this property allows you to create a custom style targeting the **Rectangle** object that visualizes the **RadDiagramItems** selection. More information about this **RadDiagram** feature you can find [here](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/items-manipulation/raddiagrams-features-selection).

## Customize the RadDiagramShape Style

You can apply a customized **Style** targeting the **RadDiagramShape** class through the **RadDiagram.ShapeStyle** property. This way you'll be able to apply one style for all shapes created inside the **RadDiagram** instance:

```XAML
<Grid>
    <Grid.Resources>
        <Style TargetType="telerik:RadDiagramShape" x:Key="CustomShapeStyle">
            <Setter Property="Background" Value="LightGreen" />
            <Setter Property="FontWeight" Value="Bold" />
        </Style>
    </Grid.Resources>
    <telerik:RadDiagram x:Name="xDiagram" ShapeStyle="{StaticResource CustomShapeStyle}">
        <telerik:RadDiagramShape x:Name="shape1" Position="20,20" Content="Shape 1" />
        <telerik:RadDiagramShape x:Name="shape2" Position="220,20" Content="Shape 2" />
        <telerik:RadDiagramConnection Source="{Binding ElementName=shape1}"
                Target="{Binding ElementName=shape2}" />
    </telerik:RadDiagram>
</Grid>
```

![Rad Diagram Styling Shape Style](https://www.telerik.com/products/wpf/documentation/assets/71e2cf6242389d519478b422105f2e23/raddiagram_styling_shapestyle.png)

However, if you have different shapes and/or you prefer to display shapes with different styles, then you should use the **ShapeStyleSelector** property. The most common use of the "selectors" is to display different kind of data based on custom logic defined inside a selector class. This is why they are usually used when implementing MVVM approach in an application. In the **RadDiagram** you can use the **ShapeStyleSelector** to apply different styles on different types of shapes when the **RadDiagram.GraphSource** collection is populated with business items. [This tutorial ](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/howto/mvvm-style-selectors) can guide you through such a scenario.

## Customize the RadDiagramContainerShape Style

The **RadDiagram.ContainerShapeStyle** property allows you to apply a custom style on all **RadDiagramContainerShape** objects displayed on the diagramming surface:

```XAML
<Grid>
    <Grid.Resources>
        <Style TargetType="telerik:RadDiagramContainerShape" x:Key="CustomContainerShapeStyle">
            <Setter Property="Background" Value="LightBlue" />
            <Setter Property="FontWeight" Value="Bold" />
            <Setter Property="Foreground" Value="Blue" />
        </Style>
    </Grid.Resources>
    <telerik:RadDiagram x:Name="xDiagram_2"
            ContainerShapeStyle="{StaticResource CustomContainerShapeStyle}">
        <telerik:RadDiagramContainerShape Position="120,120" Content="Container Shape">
            <telerik:RadDiagramShape Content="Shape 1" Position="140,160"/>
            <telerik:RadDiagramShape Content="Shape 2" Position="240,160"/>
        </telerik:RadDiagramContainerShape>
    </telerik:RadDiagram>
</Grid>
```

![Rad Diagram Styling Container Style](https://www.telerik.com/products/wpf/documentation/assets/3de263dbd03c18d6f0d36e433f80594c/raddiagram_styling_containerstyle.png)

## Customize the RadDiagramConnection Style

You can apply a customized **Style** targeting the **RadDiagramConnection** class through the **RadDiagram.ConnectionStyle** property. This way you'll be able to apply one style for all connections created inside the **RadDiagram** instance:

```XAML
<Grid>
    <Grid.Resources>
        <Style TargetType="telerik:RadDiagramConnection" x:Key="CustomConnectionStyle">
            <Setter Property="Stroke" Value="Red" />
            <Setter Property="StrokeThickness" Value="2" />
            <Setter Property="StrokeDashArray" Value="2 2" />
        </Style>
    </Grid.Resources>
    <telerik:RadDiagram x:Name="xDiagram_3"
            ConnectionStyle="{StaticResource CustomConnectionStyle}">
        <telerik:RadDiagramShape x:Name="shape1_3" Position="20,20" Content="Shape 1" />
        <telerik:RadDiagramShape x:Name="shape2_3" Position="220,20" Content="Shape 2" />
        <telerik:RadDiagramConnection Source="{Binding ElementName=shape1_3}"
                Target="{Binding ElementName=shape2_3}" />
    </telerik:RadDiagram>
</Grid>
```

![Rad Diagram Styling Connection Style](https://www.telerik.com/products/wpf/documentation/assets/ee38f8693ae19001b2aa7602a8296a39/raddiagram_styling_connectionstyle.png)

However, if you have different connections and/or you prefer to display connections with different styles, then you should use the **ConnectionStyleSelector** property. This property is very handy when creating an MVVM diagramming solution where you'd like to populate the **RadDiagram** with multiple types of connections and visualize each type differently. [This tutorial](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/howto/mvvm-style-selectors) can guide through the implementation of such an example.

## Customize the RadDiagramConnector Style

You can also apply a customized **Style** targeting the **RadDiagramConnector** class through the **RadDiagram.ConnectorStyle** property. This way you'll be able to apply one style for all connectors displayed inside a **RadDiagram** instance:

```XAML
<Grid>
    <Grid.Resources>
        <Style TargetType="telerik:RadDiagramConnector" x:Key="CustomConnectorStyle">
            <Setter Property="Background" Value="Green" />
        </Style>
    </Grid.Resources>
    <telerik:RadDiagram x:Name="xDiagram_4" ConnectorStyle="{StaticResource CustomConnectorStyle}">
        <telerik:RadDiagramShape x:Name="shape1_4" Position="20,20" Content="Shape 1" />
        <telerik:RadDiagramShape x:Name="shape2_4" Position="220,20" Content="Shape 2" />
        <telerik:RadDiagramConnection Source="{Binding ElementName=shape1_4}"
                Target="{Binding ElementName=shape2_4}" />
        <telerik:RadDiagramConnection Source="{Binding ElementName=shape2_4}"
                EndPoint="360,40" TargetCapType="Arrow1Filled"/>
    </telerik:RadDiagram>
</Grid>
```

![Rad Diagram Styling Connector Style](https://www.telerik.com/products/wpf/documentation/assets/1b154c9da84a9f0f658979742f68c2a0/raddiagram_styling_connectorstyle.png)

## Customize the RadDiagram Grouping Rectangle

Grouping, in the context of the **Telerik Diagramming Framework**, is a way of organizing shapes and connections in logical groups. Groups are non-visual, logical collections of shapes and/or connections and/or other groups. A grouping is visualized through a blue grouping  **Rectangle** object:
![Rad Diagram Styling Default Group Style](https://www.telerik.com/products/wpf/documentation/assets/4d57274ff893935d1441811bfcfd4464/raddiagram_styling_defaultgroupstyle.png)

And if you need to customize the default style settings of this rectangle, you can use the **GroupStyle** property. In the following example, the **Stroke** and **StrokeThickness** properties of the rectangle are modified to create a different look of the grouping feature:

```XAML
<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <Grid.Resources>
        <Style TargetType="Rectangle" x:Key="CustomGroupStyle">
            <Setter Property="StrokeThickness" Value="3" />
            <Setter Property="Stroke" Value="Red" />
        </Style>
    </Grid.Resources>
    <telerik:RadButton Content="Group" Click="Group" />
    <telerik:RadDiagram Grid.Row="1" x:Name="xDiagram_5"
               GroupStyle="{StaticResource CustomGroupStyle}">
        <telerik:RadDiagramShape x:Name="shape1_5" Position="20,20" Content="Shape 1" />
        <telerik:RadDiagramShape x:Name="shape2_5" Position="220,20" Content="Shape 2" />
        <telerik:RadDiagramConnection Source="{Binding ElementName=shape1_5}"
                   Target="{Binding ElementName=shape2_5}" />
    </telerik:RadDiagram>
</Grid>
```

![Rad Diagram Styling Custom Group Style](https://www.telerik.com/products/wpf/documentation/assets/1fc3e7660c04c544b0d4a56b5ae1c34e/raddiagram_styling_customgroupstyle.png)

## Customize the RadDiagram Selection Rectangle

The **RadDiagram** gives you the ability to select one or multiple **RadDiagramItems**. The default representation of this selection is a single **Rectangle** object:
![Rad Diagram Styling Default Selection Style](https://www.telerik.com/products/wpf/documentation/assets/f4171a706db8bf5f1b63b882e6ddd0b8/raddiagram_styling_defaultselectionstyle.png)

If you need to customize the style settings of the selection rectangle, you can use the **SelectionRectangleStyle** property. In the following example, you can see how to change the **Stroke** property of the rectangle to red:

```XAML
<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <Grid.Resources>
        <Style TargetType="Rectangle" x:Key="CustomSelectionRectangleStyle">
            <Setter Property="Stroke" Value="Red" />
        </Style>
    </Grid.Resources>
    <telerik:RadButton Content="Group" Click="Group" />
    <telerik:RadDiagram Grid.Row="1" x:Name="xDiagram_6" SelectionMode="Multiple"
            SelectionRectangleStyle="{StaticResource CustomSelectionRectangleStyle}">
        <telerik:RadDiagramShape x:Name="shape1_6" Position="20,20" Content="Shape 1" />
        <telerik:RadDiagramShape x:Name="shape2_6" Position="220,20" Content="Shape 2" />
        <telerik:RadDiagramConnection Source="{Binding ElementName=shape1_6}"
                Target="{Binding ElementName=shape2_6}" />
    </telerik:RadDiagram>
</Grid>
```

![Rad Diagram Styling Custom Selection Style](https://www.telerik.com/products/wpf/documentation/assets/8dfa66f89a7d2620d6cb1568635c17a0/raddiagram_styling_customselectionstyle.png)

## See Also

* [Customize Appearance](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/styles-and-templates/styling-appearance)
* [Shapes](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/diagram-items/shape/raddiagrams-features-shapes)
* [Connections](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/diagram-items/raddiagrams-features-connections)
* [Custom Connectors](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/features/custom-connectors)
* [Selection](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/items-manipulation/raddiagrams-features-selection)
* [Grouping](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/features/grouping)
