# PathButton

With our **Q3 2014** official release we introduced the RadPathButton control. It derives from the **RadButton**. This means it inherits all the features of the standard button. Additionally it adds a **Path** control to its default template. This allows you to easily add custom geometry to your button. You can instantiate this control in both XAML and code behind (see **Example 1 and 2**).

**Example 1: Defining a button in XAML**

```XAML

<telerik:RadPathButton>
    <telerik:RadPathButton.PathGeometry>
        <EllipseGeometry RadiusX="10" RadiusY="10"></EllipseGeometry>
    </telerik:RadPathButton.PathGeometry>
</telerik:RadPathButton>
```

**Example 2: Defining a button in code**

```C#
RadPathButton pathButton = new RadPathButton() { PathGeometry = new EllipseGeometry() { RadiusX = 10, RadiusY = 10 } };
```

```VB.NET
Dim pathButton As New RadPathButton() With { _
    .PathGeometry = New EllipseGeometry() With { _
        .RadiusX = 10, _
        .RadiusY = 10 _
    } _
}
```

> caption The created path button

![The created button](https://www.telerik.com/products/wpf/documentation/assets/064bef64f8f2108877852efec9eb97ee/radbuttons-features-pathbutton-0.png)

Note that in XAML you can directly use string format [Path Markup Syntax](https://docs.microsoft.com/en-us/dotnet/framework/wpf/graphics-multimedia/path-markup-syntax)

**Example 3: Setting the path geometry in XAML**

```XAML
<telerik:RadPathButton PathGeometry="M3,7L9,7L9,4L13,8L9,12L9,9L3,9z" />
```

To achieve the same results through code you can use our **GeometryParser**

**Example 3: Setting the path geometry in code**

```C#
RadPathButton pathButton = new RadPathButton() { PathGeometry = GeometryParser.GetGeometry("M3,7L9,7L9,4L13,8L9,12L9,9L3,9z") };
```

```VB.NET
Dim pathButton As New RadPathButton() With { _
    .PathGeometry = GeometryParser.GetGeometry("M3,7L9,7L9,4L13,8L9,12L9,9L3,9z") _
}
```

> caption RadPathButton with PathGeometry

![RadPathButton with PathGeometry](https://www.telerik.com/products/wpf/documentation/assets/69bb691b3ecc16900e246d062af36d54/radbuttons-features-pathbutton-1.png)

## Customizing the RadPathButton

The **RadPathButton** exposes the **ContentPlacement** property. It is of type **Dock** and gets or sets this position of the content relative to the Path element. This property accepts **Left**, **Top**, **Right** and **Bottom** values. The default is **Bottom**.

**Example 4: Setting the content position in XAML**

```XAML
<telerik:RadPathButton Content="Path Button" ContentPlacement="Right" />
```

**Example 5: Setting the content position in code**

```C#
RadPathButton pathButton = new RadPathButton() { Content = "Path button", ContentPlacement = Dock.Right };
```

```VB.NET
Dim pathButton As New RadPathButton() With { _
    .Content = "Path button", _
    .ContentPlacement = Dock.Right _
}
```

> caption RadPathButton with ContentPlacement set to right

![RadPathButton with ContentPlacement set to Right](https://www.telerik.com/products/wpf/documentation/assets/02ae1d08916614e2e01e08e37707feae/radbuttons-features-pathbutton-2.png)

In addition to all customizing options that are inherited from the **RadButton** the **PathButton** has a **PathStyle** property. This property gets or sets the style of the **Path** element in the template.

**Example 5: Setting the content position in XAML**

```XAML
<telerik:RadPathButton.PathStyle>
    <Style TargetType="Path">
        <Setter Property="Fill" Value="Red" />
        <Setter Property="Stretch" Value="Fill" />
    </Style>
</telerik:RadPathButton.PathStyle>
```

> caption RadPathButton with custom PathStyle

![RadPathButton with custom PathStyle](https://www.telerik.com/products/wpf/documentation/assets/7c194d74d2fe810927c84a3f17e2ce2d/radbuttons-features-pathbutton-3.png)

Also the **RadPathButton** exposes the **ContentMargin** property. It is of type **Thickness** and determines the margin around its content. This allows users to adjust size of the Path that the button hosts. For adjusting the position of the Path itself users can use the **RadPathButton.Padding** property.

## Aligning the Path

By default, the **Stretch** property of the **Path** element is set to **Fill**. As a result, when the **ContentPlacement** of the button is set to **Top** or **Bottom**, only the **HorizontalContentAlignment** takes effect. Respectively, when the **ContentPlacement** is **Left** or **Right**, only the **VerticalContentAlignment** takes effect.

With the **R1 2021 SP** release you can now more intuitively place the path element of the button relatively to its content. For the purpose, you need to set the **Stretch** property of the **Path** to **None** and set the desired horizontal and vertical alignments.

**Example 6: Setting the path alignment in XAML**

```XAML
<telerik:RadPathButton.PathStyle>
    <Style TargetType="Path">
        <Setter Property="Stretch" Value="None" />
        <Setter Property="HorizontalAlignment" Value="Right" />
        <Setter Property="VerticalAlignment" Value="Bottom" />
    </Style>
</telerik:RadPathButton.PathStyle>
```

> caption RadPathButton with different alignments

![RadPathButton with different alignments](https://www.telerik.com/products/wpf/documentation/assets/dfcf4ce1e316deb1af6d50fa089a650b/radbuttons-features-pathbutton-path-alignment.gif)

As seen in the image above you may also want to set appropriate values for the **HorizontalContentAlignment** and **VerticalContentAlignment** of the RadPathButton to align the content in the available space.

## RadPathButton and RadGlyph

The RadPathButton can also be used with [RadGlyphs](https://www.telerik.com/products/wpf/documentation/styling-and-appearance/glyphs/common-styles-appearance-glyphs-radglyph).

**Example 7: Set RadGlyph as PathGeometry**

```XAML
<telerik:RadPathButton Width="50" Height="50" Padding="10"
							PathGeometry="{telerik:RadGlyph Glyph={StaticResource GlyphGlobe}}" />
```

> caption RadPathButton with RadGlyph

![RadPathButton with RadGlyph](https://www.telerik.com/products/wpf/documentation/assets/978d24ed0c7b56871ea1442feb14fad9/radbuttons-features-pathbutton-4.png)

## See Also

* [Button](https://www.telerik.com/products/wpf/documentation/controls/radbuttons/features/button)
* [DropDown Button](https://www.telerik.com/products/wpf/documentation/controls/radbuttons/features/dropdown-button)
* [Split Button](https://www.telerik.com/products/wpf/documentation/controls/radbuttons/features/split-button)
* [Commands](https://www.telerik.com/products/wpf/documentation/controls/radbuttons/commands)
