static void AddInline(TextBlock textBlock, Forms9Patch.Label label, MetaFont metaFont, string text, int startIndex, int length) { var run = new Run(); run.Text = text.Substring(startIndex, length); run.FontSize = metaFont.Size; run.FontWeight = metaFont.Bold ? Windows.UI.Text.FontWeights.Bold : Windows.UI.Text.FontWeights.Normal; run.FontStyle = metaFont.Italic ? Windows.UI.Text.FontStyle.Italic : Windows.UI.Text.FontStyle.Normal; if (TextDecorationsPresent && metaFont.Strikethrough) { ApplyTextDecorations(run, Decoration.Strikethrough); } switch (metaFont.Baseline) { case FontBaseline.Numerator: run.FontFamily = new Windows.UI.Xaml.Media.FontFamily("Cambria"); Typography.SetVariants(run, Windows.UI.Xaml.FontVariants.Superscript); break; case FontBaseline.Superscript: run.FontFamily = new Windows.UI.Xaml.Media.FontFamily("Cambria"); Typography.SetVariants(run, Windows.UI.Xaml.FontVariants.Superscript); break; case FontBaseline.Denominator: run.FontFamily = new Windows.UI.Xaml.Media.FontFamily("Cambria"); Typography.SetVariants(run, Windows.UI.Xaml.FontVariants.Subscript); break; case FontBaseline.Subscript: run.FontFamily = new Windows.UI.Xaml.Media.FontFamily("Cambria"); Typography.SetVariants(run, Windows.UI.Xaml.FontVariants.Subscript); break; default: if (metaFont.Family != null) { run.FontFamily = new Windows.UI.Xaml.Media.FontFamily(FontService.ReconcileFontFamily(metaFont.Family)); } break; } if (!metaFont.BackgroundColor.IsDefaultOrTransparent()) { try { textBlock.ApplyBackgroundColor(metaFont.BackgroundColor, startIndex, length); } catch (Exception) { //throw new Exception("It appears that this Xamarin.Forms.UWP app was built with a Windows TargetVersion < 10.0.16299.0 (Windows 10 Fall Creators Update). 10.0.16299.0 is needed to support Forms9Patch.Label.HtmlText background color attributes.", e); } } if (metaFont.IsActionEmpty()) { run.Foreground = new Windows.UI.Xaml.Media.SolidColorBrush(metaFont.TextColor.ToWindowsColor()); if (TextDecorationsPresent && metaFont.Underline) { ApplyTextDecorations(run, Decoration.Underline); } textBlock.Inlines.Add(run); } else { run.Foreground = new Windows.UI.Xaml.Media.SolidColorBrush(Xamarin.Forms.Color.Blue.ToWindowsColor()); if (TextDecorationsPresent) { ApplyTextDecorations(run, Decoration.Underline); } var hyperlink = new Hyperlink(); hyperlink.Inlines.Add(run); hyperlink.Click += (Hyperlink sender, HyperlinkClickEventArgs args) => label.Tap(metaFont.Action.Id, metaFont.Action.Href); textBlock.Inlines.Add(hyperlink); } }