后台添加Textbox

 1         /// <summary>
 2         /// behind add textbox
 3         /// </summary>
 4         private void AddTextToTextBox()
 5         {
 6             TextBlock tb = new TextBlock();
 7             tb.TextWrapping = TextWrapping.Wrap;
 8             tb.Margin = new Thickness(10);
 9             tb.Inlines.Add("An example on ");
10             tb.Inlines.Add(new Run("the TextBlock control ") { FontWeight = FontWeights.Bold });
11             tb.Inlines.Add("using ");
12             tb.Inlines.Add(new Run("inline ") { FontStyle = FontStyles.Italic });
13             tb.Inlines.Add(new Run("text formatting ") { Foreground = Brushes.Blue });
14             tb.Inlines.Add("from ");
15             tb.Inlines.Add(new Run("Code-Behind") { TextDecorations = TextDecorations.Underline });
16             tb.Inlines.Add(".");
17             this.sp_text.Children.Add(tb);
18         }
原文地址:https://www.cnblogs.com/ants_double/p/5366432.html