博客园 首页 私信博主 显示目录 隐藏目录 管理 动画

后台添加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         }

 

posted @ 2016-04-08 08:05  ants_double  阅读(110)  评论(0编辑  收藏  举报