Sha*_*wal 9 silverlight textblock dynamic-data windows-phone-7
我正在用C#开发window phone 7应用程序.我是窗口手机7应用程序的新手.我也是银光的新手.我想动态生成Texblock的粗体文本.我想仅为文本的某些部分生成粗体文本.我使用以下代码
IncometextBlock.Text = "Income entries on " + selectedDate.ToShortDateString() + " Page - "+SelectedButtonName+"";
Run Code Online (Sandbox Code Playgroud)
我希望输出为
" 2011 年1月21日收入条目页面 - A "
我想要上面的输出.如何制作上述要求的粗体文字?能否请您提供我可以解决上述问题的任何代码或链接.如果我做错了什么,请指导我.
Ant*_*nes 24
我会这样做的.
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});
Run Code Online (Sandbox Code Playgroud)
如果您使用WrapPanel(来自Toolkit),您可以这样做:
<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>
Run Code Online (Sandbox Code Playgroud)
(以上只是在网格中,以便在SO中启用代码突出显示,并且不需要使效果起作用.)
| 归档时间: |
|
| 查看次数: |
12830 次 |
| 最近记录: |