问题描述
我正在用C#开发Window Phone 7应用程序。我是Window Phone 7应用程序的新手。我也是新手。我想动态生成Texblock的粗体文本。我只想为文本的某些部分生成粗体文本。我正在使用以下代码
I am developing window phone 7 application in C#. I am new to the window phone 7 application. I am also new to the silverlight. I want to generate the bold text of Texblock dynamically. I want to generate the bold text only for some part of the text. I am using the following code
IncometextBlock.Text = "Income entries on " + selectedDate.ToShortDateString() + " Page - "+SelectedButtonName+"";
我希望输出为
2011年1月21日上的收入条目- A
我想要以上输出。如何使以上要求的粗体显示?您能否提供给我任何可以解决上述问题的代码或链接。如果我做错了什么,请指导我。
I want the above output. How to make the bold text for above requirement ? Can you please provide me any code or link through which I can resolve the above issue. If I am doing anything wrong then please guide me.
推荐答案
我会这样做。
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});
这篇关于如何在Silverlight中使TextBlock的文本变为粗体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!