I'm trying to use RichEditBox in a UWP custom component, which would be added to a WPF application through XamlIslands:
<RichEditBox x:Name="editor" PointerPressed="editor_PointerPressed" Tapped="editor_Tapped" PointerReleased="editor_PointerPressed">
I add hyperlinks with the following way:
editor.Document.Selection.Link = "\"[the link]\"";
It works fine and it opens the link in the browser when Ctrl+Click on it, but how can I catch that click event?
None of the callbacks are fire which I defined as a parameter in RichEditBox, so no PointerPressed, no PointerReleased, and no Tapped events are fired at all.
I managed to do it like this:
public class CustomRichTextBox: RichEditBox
{
protected override void OnTapped(TappedRoutedEventArgs e)
{
base.OnTapped(e);
var tappedPoint = e.GetPosition(this);
var textRange = Document.GetRangeFromPoint(tappedPoint, PointOptions.ClientCoordinates);
textRange.StartOf(TextRangeUnit.Link, true);
var mylink = textRange.Link;
}
}