|
1 | | -# How-to-create-a-hyperlink-Column-in-MAUI-DataGrid- |
| 1 | +# How to create hyperlink column in MAUI DataGrid? |
| 2 | +The [.NET MAUI DataGrid(SfDataGrid)](https://www.syncfusion.com/maui-controls/maui-datagrid) does not natively provide HyperlinkColumn support. You can achieve this by using [DataGridTemplateColumn](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.DataGrid.DataGridTemplateColumn.html) and a customized label. |
| 3 | + |
| 4 | +## XAML |
| 5 | +Define your DataGrid with the required customizations. Use a DataGridTemplateColumn to load a customized label for your HyperlinkColumn. |
| 6 | + |
| 7 | +```XML |
| 8 | +<syncfusion:SfDataGrid x:Name="dataGrid" |
| 9 | + ItemsSource="{Binding ControlInfoCollection}" |
| 10 | + ColumnWidthMode="Auto"> |
| 11 | + <syncfusion:SfDataGrid.Columns> |
| 12 | + <syncfusion:DataGridTextColumn MappingName="Control"/> |
| 13 | + <syncfusion:DataGridTextColumn MappingName="Platform"/> |
| 14 | + <syncfusion:DataGridTemplateColumn MappingName="UGLink"> |
| 15 | + <syncfusion:DataGridTemplateColumn.CellTemplate> |
| 16 | + <DataTemplate> |
| 17 | + <local:HyperlinkLabel Text="User Guide documentation" |
| 18 | + Url="{Binding UGLink}" |
| 19 | + VerticalTextAlignment="Center"/> |
| 20 | + </DataTemplate> |
| 21 | + </syncfusion:DataGridTemplateColumn.CellTemplate> |
| 22 | + </syncfusion:DataGridTemplateColumn> |
| 23 | + </syncfusion:SfDataGrid.Columns> |
| 24 | +</syncfusion:SfDataGrid> |
| 25 | +``` |
| 26 | + |
| 27 | +## C# |
| 28 | +Define a customLabel named HyperlinkLabel that is inherited from Label. This customized control will represent the clickable hyperlink within the TemplateColumn. |
| 29 | + |
| 30 | +### HyperlinkLabel.cs |
| 31 | + |
| 32 | + ```C# |
| 33 | +public class HyperlinkLabel : Label |
| 34 | +{ |
| 35 | + public static readonly BindableProperty UrlProperty = BindableProperty.Create(nameof(Url), typeof(string), typeof(HyperlinkLabel), null); |
| 36 | + |
| 37 | + public string Url |
| 38 | + { |
| 39 | + get { return (string)GetValue(UrlProperty); } |
| 40 | + set { SetValue(UrlProperty, value); } |
| 41 | + } |
| 42 | + |
| 43 | + public HyperlinkLabel() |
| 44 | + { |
| 45 | + TextDecorations = TextDecorations.Underline; |
| 46 | + TextColor = Colors.Blue; |
| 47 | + GestureRecognizers.Add(new TapGestureRecognizer |
| 48 | + { |
| 49 | + Command = new Command(async () => await Launcher.OpenAsync(Url)) |
| 50 | + }); |
| 51 | + |
| 52 | + } |
| 53 | +} |
| 54 | + ``` |
| 55 | + |
| 56 | + |
| 57 | +The following screenshot shows the Hyperlink Column in SfDataGrid. |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | +Take a moment to pursue this [documentation](https://help.syncfusion.com/maui/datagrid/overview), where you can find more about Syncfusion .NET MAUI DataGrid (SfDataGrid) with code examples. |
| 62 | +Please refer to this [link](https://www.syncfusion.com/maui-controls/maui-datagrid) to learn about the essential features of Syncfusion .NET MAUI DataGrid(SfDataGrid). |
| 63 | +### Conclusion |
| 64 | +I hope you enjoyed learning about how to create Hyperlink Column in MAUI DataGrid (SfDataGrid). |
| 65 | + |
| 66 | +You can refer to our [.NET MAUI DataGrid’s feature tour](https://www.syncfusion.com/maui-controls/maui-datagrid) 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. |
| 67 | +For current customers, you can check out our .NET MAUI components from the [License and Downloads](https://www.syncfusion.com/account/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. |
| 68 | +If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our [support forums](https://www.syncfusion.com/forums), [Direct-Trac](https://support.syncfusion.com/account/login?ReturnUrl=%2Faccount%2Fconnect%2Fauthorize%2Fcallback%3Fclient_id%3Dc54e52f3eb3cde0c3f20474f1bc179ed%26redirect_uri%3Dhttps%253A%252F%252Fsupport.syncfusion.com%252Fagent%252Flogincallback%26response_type%3Dcode%26scope%3Dopenid%2520profile%2520agent.api%2520integration.api%2520offline_access%2520kb.api%26state%3D8db41f98953a4d9ba40407b150ad4cf2%26code_challenge%3DvwHoT64z2h21eP_A9g7JWtr3vp3iPrvSjfh5hN5C7IE%26code_challenge_method%3DS256%26response_mode%3Dquery) or [feedback portal](https://www.syncfusion.com/feedback/maui?control=sfdatagrid). We are always happy to assist you! |
0 commit comments