Blue Theme Orange Theme Green Theme Red Theme
 
Nevron Gauge for SharePoint
Home | Forums | Videos | Photos | Blogs | Beginners | Advertise with Us
 | Consulting  
Submit an Article Submit a Blog 
Search :       Advanced Search »
Home » Blogs Home » Blog Detail

Colors and Brushes for Text Foreground

 by Dinesh Beniwal on Oct 05, 2009

The Foreground property enables you to specify a Brush for the rendered text.
Comments: 0 Views: 6736 Printable Version 

The Foreground property enables you to specify a Brush for the rendered text. The following XAML example shows the simplest usage for Foreground, which is to use a named color string that applies a SolidColorBrush of that color to the text. Notice that Foreground is set separately on TextBlock and on each of the Run text elements within it.

XAML

<!-- TextBlock with different brushes applied to parts of the text. -->
<TextBlock
  FontFamily=
"Verdana"
  Foreground=
"Navy">
  Navy
  <Run Text=
"DodgerBlue " Foreground="DodgerBlue"/>
  <Run Text=
"LightSteelBlue " Foreground="LightSteelBlue"/>
</TextBlock>

A solid color is not the only way to apply a foreground to a font. You can use any of the Brush derived classes in Silverlight, including RadialGradientBrush, LinearGradientBrush, ImageBrush and VideoBrush. If you specify these brushes in XAML, you must use property element syntax, or use a reference such as a resource reference. The following XAML shows an example of using property element syntax and specifying an ImageBrush for text:

XAML

<TextBlock Text=
"SHRUBBERY">
  <TextBlock.Foreground>
    <ImageBrush ImageSource=
"forest.jpg"/>
  </TextBlock.Foreground>
</TextBlock>

Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
 
What do you say about this post? Post a comment here
*Title:
*Comment:
 
Comments not available.
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor

 Blogger's Profile
Age: Not Available
Location:
Title: Tech Lead
Joined: Nov 04, 2008
Education: Masters Degree
 More Blogs from this Blogger
Initializing Compound Values
Deferred Query Evaluation
Extension Methods
Lambda Expressions and Expression Trees
Getting Started with Standard Query Operators
.NET Language-Integrated Query
Window Resizing
The Layout System in Silverlight
The Silverlight Plug-in Position and Dimensions
Colors and Brushes for Text Foreground
View all »
 Latest Blogs
Initializing Compound Values
Deferred Query Evaluation
Extension Methods
Lambda Expressions and Expression Trees
Getting Started with Standard Query Operators
.NET Language-Integrated Query
Window Resizing
The Layout System in Silverlight
The Silverlight Plug-in Position and Dimensions
Colors and Brushes for Text Foreground
View all »
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 
Team Foundation Server Hosting
 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.