Skip to main content
DataGridHyperlinkColumn Class
 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Represents a DataGrid column that hosts Uri elements in its cells.

Namespace:   System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)

SystemObject
   System.Windows.ThreadingDispatcherObject
     System.WindowsDependencyObject
       System.Windows.ControlsDataGridColumn
         System.Windows.ControlsDataGridBoundColumn
          System.Windows.ControlsDataGridHyperlinkColumn

public class DataGridHyperlinkColumn : DataGridBoundColumn
public ref class DataGridHyperlinkColumn : DataGridBoundColumn
type DataGridHyperlinkColumn = 
    class
        inherit DataGridBoundColumn
    end
Public Class DataGridHyperlinkColumn
	Inherits DataGridBoundColumn
NameDescription
System_CAPS_pubmethod DataGridHyperlinkColumn

Initializes a new instance of the DataGridHyperlinkColumn class.

NameDescription
System_CAPS_pubproperty

Gets the current width of the column, in device-independent units (1/96th inch per unit).(Inherited from DataGridColumn.)

System_CAPS_pubproperty

Gets or sets the binding that associates the column with a property in the data source.(Inherited from DataGridBoundColumn.)

System_CAPS_pubproperty

Gets or sets a value that indicates whether the user can change the column display position by dragging the column header.(Inherited from DataGridColumn.)

System_CAPS_pubproperty

Gets or sets a value that indicates whether the user can adjust the column width by using the mouse.(Inherited from DataGridColumn.)

System_CAPS_pubproperty

Gets or sets a value that indicates whether the user can sort the column by clicking the column header.(Inherited from DataGridColumn.)

System_CAPS_pubproperty

Gets or sets the style that is used to render cells in the column.(Inherited from DataGridColumn.)

System_CAPS_pubproperty

Gets or sets the binding object to use when getting or setting cell content for the clipboard.(Inherited from DataGridBoundColumn.)

System_CAPS_pubproperty

Gets or sets the binding to the text of the hyperlink.

System_CAPS_protproperty

Gets the DataGrid control that contains this column.(Inherited from DataGridColumn.)

System_CAPS_pubproperty System_CAPS_static

The default value of the property.

System_CAPS_pubproperty System_CAPS_static

The default value of the property.

System_CAPS_pubproperty

Gets the DependencyObjectType that wraps the CLR type of this instance. (Inherited from DependencyObject.)

System_CAPS_pubproperty

Gets the Dispatcher this DispatcherObject is associated with. (Inherited from DispatcherObject.)

System_CAPS_pubproperty

Gets or sets the display position of the column relative to the other columns in the DataGrid.(Inherited from DataGridColumn.)

System_CAPS_pubproperty

Gets or sets the style object to apply to the column header during a drag operation.(Inherited from DataGridColumn.)

System_CAPS_pubproperty

Gets or sets the style that is used when rendering the element that the column displays for a cell in editing mode.(Inherited from DataGridBoundColumn.)

System_CAPS_pubproperty

Gets or sets the style that is used when rendering the element that the column displays for a cell that is not in editing mode.(Inherited from DataGridBoundColumn.)

System_CAPS_pubproperty

Gets or sets the content of the column header.(Inherited from DataGridColumn.)

System_CAPS_pubproperty

Gets or sets the format pattern to apply to the content of the column header.(Inherited from DataGridColumn.)

System_CAPS_pubproperty

Gets or sets the style that is used when rendering the column header.(Inherited from DataGridColumn.)

System_CAPS_pubproperty

Gets or sets the template that defines the visual representation of the column header.(Inherited from DataGridColumn.)

System_CAPS_pubproperty

Gets or sets the object that selects which template to use for the column header.(Inherited from DataGridColumn.)

System_CAPS_pubproperty

Gets a value that indicates whether the column is auto-generated.(Inherited from DataGridColumn.)

System_CAPS_pubproperty

Gets a value that indicates whether the column is prevented from scrolling horizontally.(Inherited from DataGridColumn.)

System_CAPS_pubproperty

Gets or sets a value that indicates whether cells in the column can be edited.(Inherited from DataGridColumn.)

System_CAPS_pubproperty

Gets a value that indicates whether this instance is currently sealed (read-only).(Inherited from DependencyObject.)

System_CAPS_pubproperty

Gets or sets the maximum width constraint of the column.(Inherited from DataGridColumn.)

System_CAPS_pubproperty

Gets or sets the minimum width constraint of the column.(Inherited from DataGridColumn.)

System_CAPS_pubproperty

Gets or sets the sort direction (ascending or descending) of the column.(Inherited from DataGridColumn.)

System_CAPS_pubproperty

Gets or sets a property name, or a period-delimited hierarchy of property names, that indicates the member to sort by.(Inherited from DataGridColumn.)

System_CAPS_pubproperty

Gets or sets the name of a target window or frame for the hyperlink.

System_CAPS_pubproperty

Gets or sets the visibility of the column.(Inherited from DataGridColumn.)

System_CAPS_pubproperty

Gets or sets the column width or automatic sizing mode.(Inherited from DataGridColumn.)

NameDescription
System_CAPS_protmethod CancelCellEdit

Causes the column cell being edited to revert to the specified value.(Overrides DataGridColumnCancelCellEdit.)

System_CAPS_pubmethod CheckAccess

Determines whether the calling thread has access to this DispatcherObject.(Inherited from DispatcherObject.)

System_CAPS_pubmethod ClearValue

Clears the local value of a property. The property to be cleared is specified by a DependencyProperty identifier. (Inherited from DependencyObject.)

System_CAPS_pubmethod ClearValue

Clears the local value of a read-only property. The property to be cleared is specified by a DependencyPropertyKey. (Inherited from DependencyObject.)

System_CAPS_pubmethod CoerceValue

Coerces the value of the specified dependency property. This is accomplished by invoking any CoerceValueCallback function specified in property metadata for the dependency property as it exists on the calling DependencyObject.(Inherited from DependencyObject.)

System_CAPS_protmethod CommitCellEdit

Performs any required validation before exiting edit mode.(Overrides DataGridColumnCommitCellEdit.)

System_CAPS_pubmethod Equals

Determines whether a provided DependencyObject is equivalent to the current DependencyObject.(Inherited from DependencyObject.)

System_CAPS_protmethod Finalize

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_protmethod GenerateEditingElement

Gets an editable TextBox element that is bound to the column's property value.(Overrides DataGridColumnGenerateEditingElement.)

System_CAPS_protmethod GenerateElement

Gets a read-only Hyperlink element that is bound to the column's property value.(Overrides DataGridColumnGenerateElement.)

System_CAPS_pubmethod GetCellContent

Retrieves the property value for the cell at the intersection of this column and the specified row.(Inherited from DataGridColumn.)

System_CAPS_pubmethod GetCellContent

Gets the property value for the cell at the intersection of this column and the row that represents the specified data item.(Inherited from DataGridColumn.)

System_CAPS_pubmethod GetHashCode

Gets a hash code for this DependencyObject.(Inherited from DependencyObject.)

System_CAPS_pubmethod GetLocalValueEnumerator

Creates a specialized enumerator for determining which dependency properties have locally set values on this DependencyObject. (Inherited from DependencyObject.)

System_CAPS_pubmethod GetType

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethod GetValue

Returns the current effective value of a dependency property on this instance of a DependencyObject. (Inherited from DependencyObject.)

System_CAPS_pubmethod InvalidateProperty

Re-evaluates the effective value for the specified dependency property(Inherited from DependencyObject.)

System_CAPS_protmethod MemberwiseClone

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_protmethod NotifyPropertyChanged

Notifies the DataGrid that contains this column that a column property has changed.(Inherited from DataGridColumn.)

System_CAPS_protmethod OnBindingChanged

Notifies the DataGrid when the value of the property changes.(Inherited from DataGridBoundColumn.)

System_CAPS_protmethod OnCoerceIsReadOnly

Determines the value of the property based on property rules from the data grid that contains this column.(Inherited from DataGridBoundColumn.)

System_CAPS_protmethod OnContentBindingChanged

Notifies the DataGrid when the property changes.

System_CAPS_pubmethod OnCopyingCellClipboardContent

Raises the CopyingCellClipboardContent event.(Inherited from DataGridColumn.)

System_CAPS_pubmethod OnPastingCellClipboardContent

Raises the PastingCellClipboardContent event.(Inherited from DataGridColumn.)

System_CAPS_protmethod OnPropertyChanged

Invoked whenever the effective value of any dependency property on this DependencyObject has been updated. The specific dependency property that changed is reported in the event data. (Inherited from DependencyObject.)

System_CAPS_protmethod PrepareCellForEdit

Called when a cell in the column enters editing mode.(Overrides DataGridColumnPrepareCellForEdit.)

System_CAPS_pubmethod ReadLocalValue

Returns the local value of a dependency property, if it exists. (Inherited from DependencyObject.)

System_CAPS_protmethod RefreshCellContent

Refreshes the contents of a cell in the column in response to a column property value change.(Overrides DataGridBoundColumnRefreshCellContent.)

System_CAPS_pubmethod SetCurrentValue

Sets the value of a dependency property without changing its value source. (Inherited from DependencyObject.)

System_CAPS_pubmethod SetValue

Sets the local value of a dependency property, specified by its dependency property identifier. (Inherited from DependencyObject.)

System_CAPS_pubmethod SetValue

Sets the local value of a read-only dependency property, specified by the DependencyPropertyKey identifier of the dependency property. (Inherited from DependencyObject.)

System_CAPS_protmethod ShouldSerializeProperty

Returns a value that indicates whether serialization processes should serialize the value for the provided dependency property.(Inherited from DependencyObject.)

System_CAPS_pubmethod ToString

Returns a string that represents the current object.(Inherited from Object.)

System_CAPS_pubmethod VerifyAccess

Enforces that the calling thread has access to this DispatcherObject.(Inherited from DispatcherObject.)

NameDescription
System_CAPS_pubfield System_CAPS_static TargetNameProperty

Identifies the dependency property.

NameDescription
System_CAPS_pubevent CopyingCellClipboardContent

Occurs after the cell clipboard content is prepared.(Inherited from DataGridColumn.)

System_CAPS_pubevent PastingCellClipboardContent

Occurs before the clipboard content is moved to the cell.(Inherited from DataGridColumn.)

Use DataGridHyperlinkColumn to display data that contains a Uri, such as an HTTP address or e-mail address. The following illustration shows an example of a DataGridHyperlinkColumn.

DataGridHyperlinkColumn with email addresses
System_CAPS_noteNote

Hyperlink navigation can only occur if either the direct or indirect parent of a Hyperlink is a navigation host. Examples of navigation hosts include NavigationWindow, Frame, or any browser that can host XBAPs, such as Microsoft Internet Explorer 6 or later and Firefox 2.0 or later. For more information, see the "Navigation Hosts" topic in Navigation Overview.

To populate the column, bind the column to the Uri data by using the property. To display hyperlink text that is different than the URI string, bind the text value to the property. The property is applied to the Hyperlink or TextBox element created in the column. The for the element in each cell is the data item for the row the cell is in. Therefore, to set up the binding you only have to set the . Optionally, you can specify a if you want to convert the data. For more information about data binding, see Data Binding (WPF).

System_CAPS_noteNote

DataGridHyperlinkColumn creates a Hyperlink element in the non-editing mode and a TextBox element in the editing mode.

If you want to display other types of data, DataGrid provides the following column types:

Column Type

Data Display

DataGridCheckBoxColumn

Use to display Boolean data.

DataGridComboBoxColumn

Use to display enumeration data.

DataGridTextColumn

Use to display text.

If you want to use other controls in your DataGrid, you can create your own column types by using DataGridTemplateColumn.

The following example shows a DataGridHyperlinkColumn that sets the Uri with the property and the hyperlink text with the property. The HyperlinkClick event is handled automatically because NavigationWindow is the parent of the DataGrid.

<NavigationWindow x:Class="DataGrid_CustomColumns.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:core="clr-namespace:System;assembly=mscorlib"
    xmlns:local="clr-namespace:DataGrid_CustomColumns"
    Title="Customers" Height="300" Width="300" ShowsNavigationUI="False"  >

<NavigationWindow.Resources>
    <!--Create an instance of the converter for Email-->
    <local:EmailConverter x:Key="EmailConverter" />
</NavigationWindow.Resources>
<NavigationWindow.Content>  

<Grid>
    <DataGrid Name="DG1" ItemsSource="{Binding}" AutoGenerateColumns="False" >
        <DataGrid.Columns>
<!--The Email property contains a URI.  For example "mailto:lucy0@adventure-works.com"-->
<DataGridHyperlinkColumn Header="Email" Binding="{Binding Email}"  ContentBinding="{Binding Email, Converter={StaticResource EmailConverter}}" />
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
    </NavigationWindow.Content>
</NavigationWindow>
public partial class Window1 : NavigationWindow
{
Class Window1
public Window1()
{
    InitializeComponent();

    //GetData() creates a collection of Customer data from a database
    ObservableCollection<Customer> custdata = GetData();

    //Bind the DataGrid to the customer data
    DG1.DataContext = custdata;

}
Public Sub New()
    ' This call is required by the Windows Form Designer.
    InitializeComponent()
    ' Add any initialization after the InitializeComponent() call.

    'GetData() creates a collection of Customer data from a database
    Dim custdata As ObservableCollection(Of Customer) = GetData()

    'Bind the DataGrid to the customer data
    DG1.DataContext = custdata

End Sub
//Defines the customer object
public class Customer
{
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public Uri Email { get; set; }
    public bool IsMember { get; set; }
    public OrderStatus Status { get; set; }

}
'Defines the customer object
Public Class Customer
    Public Property FirstName() As String
    Public Property LastName() As String
    Public Property Email() As Uri
    Public Property IsMember() As Boolean
    Public Property Status() As OrderStatus
End Class
}
End Class
//Converts the mailto uri to a string with just the customer alias
public class EmailConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        if (value != null)
        {
            string email = value.ToString();
            int index = email.IndexOf("@");
            string alias = email.Substring(7, index-7);
            return alias;
        }
        else
        {
            string email = "";
            return email;
        }
    }

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        Uri email = new Uri((string)value);
        return email;
    }
}
'Converts the mailto uri to a string with just the customer alias
Public Class EmailConverter
    Implements IValueConverter

    Public Function Convert(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.Convert
        If value IsNot Nothing Then
            Dim email As String = value.ToString()
            Dim index As Integer = email.IndexOf("@")
            Dim [alias] As String = email.Substring(7, index - 7)
            Return [alias]
        Else
            Dim email As String = ""
            Return email
        End If
    End Function

    Public Function ConvertBack(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.ConvertBack
        Dim email As New Uri(DirectCast(value, String))
        Return email
    End Function
End Class
.NET Framework
Available since 4.0

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top