Geeks With Blogs

News


Timmy Kokke's Blog

↑ Grab this Headline Animator

Timmy Kokke at Blogged
Timmy Kokke …just sorting my bubbles…

silverbullet I’d like to provide you with a SilverBullet™, a small snippet of Silverlight, a class or namespace hidden in the silverlight .NET framework, to help you out in times of need. It’s not to learn, but something to keep in your pocket. Just remember it’s there and you’re safe.

When showing text to a user it's often necessary to show a few words in Italic or Bold. To do this, use the System.Windows.Documents.Run class. This class provides a small bit of HTML - like features inside a Silverlight TextBlock. But, instead of using HTML tags you have to use the Run class.

 

The Run class inherits from the abstract System.Windows.Documents.Inline which provides most of the properties to use.  A few of the most common are:

There are couple more properties which you can find here.

Another thing that might become useful when using the Run class to simulate a bit of HTML like behavior is the System.Windows.Documents.LineBreak class. This class does not have any properties or methods and can be compared to the <br /> tag in HTML.

 

Here’s a small example to show how the Run class  is used in xaml:

<Grid x:Name="LayoutRoot" Background="White"> 
    <TextBlock TextWrapping="Wrap" FontFamily="Verdana"> 
            This is an example with 
            <Run FontWeight="Black">Bold</Run>, 
            <Run FontStyle="Italic">Italic</Run> and 
            <Run Foreground="red">Colored</Run>                        
            text...<LineBreak /> 
            It's even possible to use<LineBreak />
            multiple <LineBreak />lines of text.
    </TextBlock> 
</Grid>

 

 

 

Shout it
Tags van Technorati:
dotNed blogger
kick it on DotNetKicks.com
Posted on Wednesday, September 9, 2009 5:23 PM Silverlight , SilverBullet , dotnetmag , CodeProject | Back to top


Comments on this post: SilverBullet #10 System.Windows.Documents.Run

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Timmy Kokke | Powered by: GeeksWithBlogs.net