示例#1
0
        private Inline AnchorInlineEvaluator([NotNull] Match match)
        {
            if (match == null)
            {
                throw new ArgumentNullException(nameof(match));
            }

            var linkText = match.Groups[2].Value;
            var url      = match.Groups[3].Value;
            var title    = match.Groups[6].Value;

            if (!Uri.IsWellFormedUriString(url, UriKind.Absolute) && (!System.IO.Path.IsPathRooted(url) || !url.StartsWith("/") || !url.StartsWith("\\")))
            {
                // Make relative URL absolute
                url = (BaseUrl ?? string.Empty) + url;
            }

            var result = Create <Hyperlink, Inline>(RunSpanGamut(linkText));

            // Note: cannot use Command and CommandParameter because of a WPF bug (when copying the text). See https://stackoverflow.com/questions/3206258/commandconverter-valid-exception-or-net-bug
            result.Click += (_, __) => HyperlinkCommand.Execute(url);
            return(result);
        }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FormattedTextBlock"/> class.
 /// </summary>
 public FormattedTextBlock()
 {
     _hyperlinkCommand = new HyperlinkCommand(this);
     Visibility        = Visibility.Collapsed;
 }