C#:
{ TextBlock A = new TextBlock();A.Text = "111";A.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0));Txt.Children.Add(A);A = null;TextBlock B = new TextBlock();B.Text = "222";B.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 255, 0));Txt.Children.Add(B);B = null;TextBlock C = new TextBlock();C.Text = "333";C.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 255));Txt.Children.Add(C);C = null;}需要换行加:A.TextWrapping=TextWrapping.Wrap