Formatted text in a TextBlock in Windows Phone C#

Formatted text in a TextBlock in Windows Phone C#

Advertisemen

You can also display a series of strings in a TextBlock, where each string has a different formatting. You can do this by using a Run element to display each string with its formatting and by separating each Run element with a LineBreak element.
The following XAML shows how to define several differently formatted text strings in a TextBlock by using Run objects separated with a LineBreak.

<Grid>
<TextBlock FontFamily="Arial" Width="400" >
<LineBreak/>
<Run Foreground="Maroon" FontFamily="Courier New" FontSize="40">
Courier New 24
</Run>
n style="color: blue;"><LineBreak/>
<Run Foreground="Teal" FontFamily="Times New Roman" FontSize="30" FontStyle="Italic">
Times New Roman Italic 18
</Run>
<LineBreak/>
<Run Foreground="SteelBlue" FontFamily="Verdana" FontSize="20" FontWeight="Bold">
Verdana Bold 14
</Run>
</TextBlock>
</Grid>
The following illustration shows the result of the previous XAML.
TextBlock - Text formatting
In case you want databinding to work with the multiple formatted text runs then kindly see the following link: http://stackoverflow.com/questions/5253622/databinding-textblock-runs-in-silverlight-wp7
Source: MSDN

Have a nice day by 

Advertisemen

Disclaimer: Gambar, artikel ataupun video yang ada di web ini terkadang berasal dari berbagai sumber media lain. Hak Cipta sepenuhnya dipegang oleh sumber tersebut. Jika ada masalah terkait hal ini, Anda dapat menghubungi kami disini.

Tidak ada komentar:

Posting Komentar

© Copyright 2017 Tutorial Unity 3D