WPF Hyperlink Column in Datagrid

Below i present the code snippet to create a Hyperlink column in Datagrid in a WPF application.


This is applicable when a static text with Hyperlink on it is to be shown in the grid.

< my:DataGridTemplateColumn Header="" MinWidth="100" IsReadOnly="True" >
< my:DataGridTemplateColumn.CellTemplate >
< DataTemplate >
< TextBlock >
< Hyperlink Command="{Binding DataContext.MyCommand, RelativeSource={ RelativeSource FindAncestor, AncestorType ={x:Type my:DataGrid}}}" > HyperLink Text

< /Hyperlink >
< /TextBlock >
< /DataTemplate >
< /my:DataGridTemplateColumn.CellTemplate >
< /my:DataGridTemplateColumn >


Similarly if instead of a statis text any other databound value is to be shown as link it can be specified as value to Binding attribute of Hyperlink tag.


Comments

Guest Author: Harshil09 Jul 2012

Thanks .It is very useful post.but how to change the name of the Hyperlink programatically as i replace Multilingual Value of Other Culture runtime



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: