The .NET MAUI DataGrid(SfDataGrid) does not natively provide HyperlinkColumn support. You can achieve this by using DataGridTemplateColumn and a customized label.
Define your DataGrid with the required customizations. Use a DataGridTemplateColumn to load a customized label for your HyperlinkColumn.
<syncfusion:SfDataGrid x:Name="dataGrid"
ItemsSource="{Binding ControlInfoCollection}"
ColumnWidthMode="Auto">
<syncfusion:SfDataGrid.Columns>
<syncfusion:DataGridTextColumn MappingName="Control"/>
<syncfusion:DataGridTextColumn MappingName="Platform"/>
<syncfusion:DataGridTemplateColumn MappingName="UGLink">
<syncfusion:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<local:HyperlinkLabel Text="User Guide documentation"
Url="{Binding UGLink}"
VerticalTextAlignment="Center"/>
</DataTemplate>
</syncfusion:DataGridTemplateColumn.CellTemplate>
</syncfusion:DataGridTemplateColumn>
</syncfusion:SfDataGrid.Columns>
</syncfusion:SfDataGrid>Define a customLabel named HyperlinkLabel that is inherited from Label. This customized control will represent the clickable hyperlink within the TemplateColumn.
public class HyperlinkLabel : Label
{
public static readonly BindableProperty UrlProperty = BindableProperty.Create(nameof(Url), typeof(string), typeof(HyperlinkLabel), null);
public string Url
{
get { return (string)GetValue(UrlProperty); }
set { SetValue(UrlProperty, value); }
}
public HyperlinkLabel()
{
TextDecorations = TextDecorations.Underline;
TextColor = Colors.Blue;
GestureRecognizers.Add(new TapGestureRecognizer
{
Command = new Command(async () => await Launcher.OpenAsync(Url))
});
}
}The following screenshot shows the Hyperlink Column in SfDataGrid.
Take a moment to pursue this documentation, where you can find more about Syncfusion .NET MAUI DataGrid (SfDataGrid) with code examples. Please refer to this link to learn about the essential features of Syncfusion .NET MAUI DataGrid(SfDataGrid).
I hope you enjoyed learning about how to create Hyperlink Column in MAUI DataGrid (SfDataGrid).
You can refer to our .NET MAUI DataGrid’s feature tour page to know about its other groundbreaking feature representations. You can also explore our .NET MAUI DataGrid Documentation to understand how to present and manipulate data. For current customers, you can check out our .NET MAUI components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our .NET MAUI DataGrid and other .NET MAUI components. If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac or feedback portal. We are always happy to assist you!
