吾爱去(52qu) 壹曲阳勇发布个人作品之网站

《我的记事本》编程过程(4)

下面的示例演示如何设置元素的 FontStyle 属性 TextBlock 。

<TextBlock Name="textBlock" Background="AntiqueWhite" Foreground="Navy"   
    FontFamily="Century Gothic" //字体
    FontSize="12"               //字号
    FontStretch="UltraExpanded"
    FontStyle="Italic"          //倾斜
    FontWeight="UltraBold"      //粗体
    TextDecorations=”Underline” //下划线

    LineHeight="Auto"
    Padding="5,10,5,10"
    TextAlignment="Center"      //居中
    TextWrapping="Wrap"     //自动换行

    Typography.NumeralStyle="OldStyle"
    Typography.SlashedZero="True"
    >
    <Run Background="LightGreen">Text run 1.</Run>
    <LineBreak/><Run Background="LightBlue">Text run 2.</Run>
    <LineBreak/><Run Background="LightYellow">Text run 3.</Run>
</TextBlock>

读取系统字体列表:参考

获取已安装的所有字体列表

System.Drawing.FontFamily
StringBuilder str = new StringBuilder(2000);
InstalledFontCollection fonts = new InstalledFontCollection();
foreach (FontFamily family in fonts.Families)
{
  str.Append(family.Name);
  str.AppendLine();
}
ContentTextBlock.Text = str.ToString();


2021年9月24日 | 发布:程序员 | 分类:文档分行 | 评论:0

发表留言: