# Hyperlink Column Click Handling

Handle a link click in `GridViewHyperlinkColumn` with its `HyperlinkClicked` event. Use a `GridViewDataColumn` with a custom cell template when you need to handle a different click interaction.

If the first column of the **RadGridView** is a **GridViewHyperlinkColumn**, as in the picture below:

> caption RadGridView with GridViewHyperLinkColumn

![Telerik UI for WPF RadGridView with a GridViewHyperlinkColumn before handling the click event](https://www.telerik.com/products/wpf/documentation/assets/56f8b1b52128fbf79ad36e555aee7925/gridview-hyperlinkcolumn-initial.png)

The column launches only URLs that pass the pattern and scheme checks. Absolute HTTP, HTTPS, and mailto URLs can be trusted by default when they pass those checks; other URLs do not launch unless a local or shared handler sets `IsTrustedUrl` to `true`. This launch restriction is a behavior change for GridView hyperlinks.

## Handling the Column Hyperlink Event

Subscribe to `GridViewHyperlinkColumn.HyperlinkClicked` to inspect the URL and row data or cancel navigation:

The event arguments expose the URL, trust status, handling status, and the row's data item. Set `Handled` to `true` to prevent the default launch.

**Handling a link click in GridViewHyperlinkColumn**

```C#
private void OnColumnHyperlinkClicked(object sender, GridViewHyperlinkClickedEventArgs e)
{
    if (e.DataItem == null)
    {
        e.Handled = true;
    }
}
```

`GridViewHyperlinkClickedEventArgs` provides `Url`, `IsTrustedUrl`, `Handled`, and `DataItem`. The example cancels navigation when the event does not have a row data item.

**Figure 2** shows the result after clicking the hyperlink:

> caption The result after clicking the hyperlink

![Telerik UI for WPF RadGridView after clicking a GridViewHyperlinkColumn link and showing the clicked URL](https://www.telerik.com/products/wpf/documentation/assets/1664d2ec63dc5307346460dc5094c426/gridview-hyperlink-clicked.png)

## Handling a Custom Cell Click

Declare a standard **GridViewDataColumn** instead of **GridViewHyperlinkColumn**. Subscribe to the `MouseLeftButtonUp` event of the `TextBlock` in the cell template and use a style to imitate a hyperlink:

**Declare the GridViewHyperlinkColumn and its CellTemplate:**

```XAML
<Style x:Key="HyperlinkStyle" TargetType="TextBlock">
          <Setter Property="Foreground" Value="Blue" />
          <Setter Property="TextDecorations" Value="Underline" />
      </Style>					...

  <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}">
                  <telerik:GridViewDataColumn.CellTemplate>
                      <DataTemplate>
                          <TextBlock Style="{StaticResource HyperlinkStyle}" Text="{Binding Name}" MouseLeftButtonUp="TextBlock_MouseLeftButtonUp"/>
                      </DataTemplate>
                  </telerik:GridViewDataColumn.CellTemplate>
     </telerik:GridViewDataColumn>
```

**Handle the MouseLeftButtonUp event**

```C#
private void TextBlock_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
    var teamName = (e.Source as TextBlock).Text;
    MessageBox.Show(teamName);
}
```

The result will be the same as the one shown in **Figure 2**.

## Using the Shared Hyperlink Event

`HyperlinkManager.HyperlinkClicked` runs after the column event if the column event does not handle the request. The shared event also handles links from `GridViewDynamicHyperlinkColumn`, which has no local `HyperlinkClicked` event. Set `Handled` to `true` to cancel navigation or `IsTrustedUrl` to `true` to permit a URL that is not trusted by default. The `sender` identifies the originating control or component.

The shared validator accepts absolute HTTP, HTTPS, and mailto URLs that pass its pattern and scheme checks. `HyperlinkManager.HyperlinkClicked` is static, so unsubscribe when the handler owner has a shorter lifetime than the application. For a shared-event code example, see [Handling hyperlink navigation in RadHyperlinkButton](https://www.telerik.com/products/wpf/documentation/controls/radbuttons/features/hyperlink-button).

## See Also

* [CellTemplate and CellEditTemplate](https://www.telerik.com/products/wpf/documentation/controls/radgridview/columns/celltemplate-and-celledittemplate)
* [CheckBox Column](https://www.telerik.com/products/wpf/documentation/controls/radgridview/columns/columntypes/checkbox-column)
* [Telerik UI for WPF API Reference](https://docs.telerik.com/devtools/wpf/api/)
