前台:默认即可
<Window x:Class="FormatText.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="FormatText" Height="300" Width="300" Loaded="Window_Loaded"> <Grid> </Grid> </Window>
后台:Window_Loaded(object sender,RoutedEventArgs e)事件中代码
Title = "Format the Text";
TextBlock txt = new TextBlock(); txt.FontSize = 24; // 24
txt.Inlines.Add("This is some ");
txt.Inlines.Add(new Italic(new Run("italic"))); txt.Inlines.Add