2012-08-31 31 views

回答

3

您可以在XAML的TextBlock中单独设置样式运行,也可以在.cs代码隐藏文件中使用Inlines属性。 This blog post表示您可以至少设置字体样式,字体重量,前景色和字体大小。

XAML:

<TextBlock> 
    <Run Text="SomeText" FontWeight="Bold" FontStyle="Italic"/> 
    <Run Text=" some more text" FontSize="12"/> 
    <Run Text=" and more" Foreground="Blue"/> 
</TextBlock > 

下面是显示来自C# Corner加入刷到了运行的例子:

<Run.Foreground> 
    <LinearGradientBrush> 
     <GradientStop Color="Green" Offset="0.0" /> 
     <GradientStop Color="Purple" Offset="0.25" /> 
     <GradientStop Color="Orange" Offset="0.5" /> 
     <GradientStop Color="Blue" Offset="0.75" /> 
    </LinearGradientBrush> 
</Run.Foreground> 

Inlines收集您可以通过编程访问是System.Windows.Documents.Run对象的集合。

2

尝试使用奔跑,你可以把尽可能多的人在的TextBlock段落,只要你愿意,他们聪明是非常高效的性能。

你也可以使用绑定为文字一个Run的属性,挺酷的!

<TextBlock> 
    <Run Text="I want to show you some" /> 
    <Run Text="bold" 
     FontWeight="Bold" /> 
    <Run Text="text!" /> 
</TextBlock> 
+0

这就是我一直在寻找的。谢谢! –

相关问题