我有一组我想放在肚里像这样一个RichTextBox的文字:
所以我用一个RichTextBox,因为它可以让我做到以下几点。
var zipCodeParagraph = new Paragraph();
string zipCodes = String.Empty;
var dateRun = new Underline(new Run(DateTime.Today.DayOfWeek + ", " + CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(DateTime.Today.Month) + ' ' + DateTime.Today.Day));
Underline dateSuperscript;
switch (DateTime.Today.Day % 10)
{
case 1:
dateSuperscript = new Underline(new Run("st"));
break;
case 2:
dateSuperscript = new Underline(new Run("nd"));
break;
case 3:
dateSuperscript = new Underline(new Run("rd"));
break;
default:
dateSuperscript = new Underline(new Run("th"));
break;
}
dateSuperscript.BaselineAlignment = BaselineAlignment.Superscript;
if (ZipCodes.Any())
{
zipCodeParagraph.Inlines.Add(new Run("The following zip codes are facing a "));
zipCodeParagraph.Inlines.Add(new Underline(new Run("Severe Weather Threat")));
zipCodeParagraph.Inlines.Add(new Run(" on "));
zipCodeParagraph.Inlines.Add(dateRun);
zipCodeParagraph.Inlines.Add(dateSuperscript);
zipCodes = String.Join(", ", ZipCodes.ToArray());
}
然而,结果是像这样:
的问题是,改变文本的基线时是标/下标然后下划线变化到高度为好。 我想下划线留它在哪里,并为超级脚本发生为好。
我发现只有一个接近解决方案,它不这样做编程方式在这里 。