我正在开发C#中的窗口电话7应用程序.我是新手机7的应用程序.我也是Silverlight的新手.我想动态地生成Texblock的粗体文本.我想为文本的某些部分生成粗体文本.我正在使用以下代码
IncometextBlock.Text = "Income entries on " + selectedDate.ToShortDateString() + " Page - "+SelectedButtonName+"";
我想输出为
“2011年1月21日收入条目页 – A”
解决方法
我会这样做
IncometextBlock.Inlines.Clear(); IncometextBlock.Inlines.Add(new Run() {Text = "Income entries",FontWeight = FontWeights.Bold}); IncometextBlock.Inlines.Add(new Run() {Text = " on " }); IncometextBlock.Inlines.Add(new Run() {Text = selectedDate.ToShortDateString(),FontWeight = FontWeights.Bold}); IncometextBlock.Inlines.Add(new Run() {Text = " Page - "}); IncometextBlock.Inlines.Add(new Run() {Text = SelectedButtonName,FontWeight = FontWeights.Bold});