如何在Silverlight中使TextBlock的文本加粗?

如何在Silverlight中使TextBlock的文本加粗?,silverlight,windows-phone-7,dynamic-data,textblock,Silverlight,Windows Phone 7,Dynamic Data,Textblock,我正在用C#开发WindowsPhone7应用程序。我不熟悉Windows phone 7应用程序。我对silverlight也是新手。我想动态生成Texblock的粗体文本。我只想为部分文本生成粗体文本。我正在使用以下代码 IncometextBlock.Text = "Income entries on " + selectedDate.ToShortDateString() + " Page - "+SelectedButtonName+""; 我希望输出为 “2011年1

我正在用C#开发WindowsPhone7应用程序。我不熟悉Windows phone 7应用程序。我对silverlight也是新手。我想动态生成Texblock的粗体文本。我只想为部分文本生成粗体文本。我正在使用以下代码

IncometextBlock.Text = "Income entries on " + selectedDate.ToShortDateString() + "        Page - "+SelectedButtonName+"";
我希望输出为

2011年1月21日收入分录第页-A

我想要上面的输出。如何为上述要求制作粗体文本?你能提供我任何代码或链接,通过它我可以解决上述问题。如果我做错了什么,请指导我

如果使用WrapPanel(),可以执行以下操作:

<Grid>
    <toolkit:WrapPanel>
        <TextBlock Text="Income entries" FontWeight="Bold"/>
        <TextBlock Text=" on "/>
        <TextBlock Text="21/01/2011" FontWeight="Bold"/>
        <TextBlock Text=" Page - "/>
        <TextBlock Text="A" FontWeight="Bold"/>
    </toolkit:WrapPanel>
</Grid>

(上面的网格只是为了在SO中启用代码高亮显示,而不需要这样做才能产生效果。)

我会这样做

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});

WP7支持文本块中的
Run
文本元素,文本块可以更有效地处理文本换行。在我看来,使用工具包重炮来解决这个小问题有点像OTT。如果你的数据是数据绑定的呢?