1

XamlIslands を介して WPF アプリケーションに追加される UWP カスタム コンポーネントで RichEditBox を使用しようとしています。

<RichEditBox x:Name="editor" PointerPressed="editor_PointerPressed" Tapped="editor_Tapped" PointerReleased="editor_PointerPressed">

次の方法でハイパーリンクを追加します。

editor.Document.Selection.Link = "\"[the link]\"";

正常に動作し、Ctrl キーを押しながらクリックするとブラウザーでリンクが開きますが、そのクリック イベントをキャッチするにはどうすればよいですか?

RichEditBox でパラメーターとして定義したコールバックは発生しないため、PointerPressed、PointerReleased、および Tapped イベントはまったく発生しません。

4

2 に答える 2

0

私はこのようにそれを行うことができました:

   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;
    }
}
于 2022-01-21T09:10:41.480 に答える