void OnHyperLinkClick(object sender, EventArgs e) #endif { #if WPF Hyperlink hyperlinkControl; //Content is TetxBlock, so we need to get the Hyperlink from Inlines of TextBlock if (sender is TextBlock) { hyperlinkControl = (sender as TextBlock).Inlines.Cast <Hyperlink>().FirstOrDefault(); } else { hyperlinkControl = (Hyperlink)sender; } #else var hyperlinkControl = (HyperlinkButton)sender; #endif TreeGridCell gridcell = null; #if UWP if (hyperlinkControl.Parent is TreeGridCell) { gridcell = hyperlinkControl.Parent as TreeGridCell; } #else if (hyperlinkControl.Parent is TextBlock) { var textBlock = hyperlinkControl.Parent as TextBlock; gridcell = textBlock.Parent as TreeGridCell; } #endif var navigateText = string.Empty; var rowColumnIndex = RowColumnIndex.Empty; rowColumnIndex.RowIndex = gridcell != null ? gridcell.ColumnBase.RowIndex : new RowColumnIndex().RowIndex; rowColumnIndex.ColumnIndex = gridcell != null ? gridcell.ColumnBase.ColumnIndex : new RowColumnIndex().ColumnIndex; if (!rowColumnIndex.IsEmpty) { this.TreeGrid.SelectionController.HandlePointerOperations(new GridPointerEventArgs(PointerOperation.Pressed, null), rowColumnIndex); this.TreeGrid.SelectionController.HandlePointerOperations(new GridPointerEventArgs(PointerOperation.Released, null), rowColumnIndex); } if (hyperlinkControl.NavigateUri != null) { navigateText = hyperlinkControl.NavigateUri.ToString(); } else { if (rowColumnIndex != null && !rowColumnIndex.IsEmpty) { //Get the column from rowColumnIndex. var column = this.TreeGrid.Columns[this.TreeGrid.ResolveToGridVisibleColumnIndex(rowColumnIndex.ColumnIndex)]; column.ColumnWrapper.DataContext = hyperlinkControl.DataContext; if (column.ColumnWrapper.Value != null) { navigateText = column.ColumnWrapper.Value.ToString(); } } } if (TreeGrid.CurrentCellRequestNavigateEvent(new CurrentCellRequestNavigateEventArgs(TreeGrid) { NavigateText = navigateText, RowData = hyperlinkControl.DataContext, RowColumnIndex = rowColumnIndex })) { return; } const string pattern = @"((http|https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)"; //the hyperlink value is stored in the variable navigateText. if (navigateText != null) { var NavigateUri = Regex.IsMatch(navigateText.ToString(), pattern) ? new Uri(navigateText.ToString()) : null; if (NavigateUri == null) { return; } hyperlinkControl.NavigateUri = NavigateUri; #if WPF Process.Start(new ProcessStartInfo(hyperlinkControl.NavigateUri.AbsoluteUri)); #else if (e is KeyRoutedEventArgs && (e as KeyRoutedEventArgs).Key == Key.Space) { await Launcher.LaunchUriAsync(new Uri(hyperlinkControl.NavigateUri.AbsoluteUri)); } #endif } }