Use a gradient to paint TextBlock : TextBlock « UI Controls « Silverlight






Use a gradient to paint TextBlock

Use a gradient to paint TextBlock
    

<UserControl x:Class='SilverlightApplication3.MainPage'
    xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' 
    xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
    xmlns:d='http://schemas.microsoft.com/expression/blend/2008' 
    xmlns:mc='http://schemas.openxmlformats.org/markup-compatibility/2006' 
    mc:Ignorable='d' 
    d:DesignWidth='640' 
    d:DesignHeight='480'>
  <Canvas>

     <TextBlock Margin="5"  FontWeight="Bold" FontSize="65" TextWrapping="Wrap" TextAlignment="Center">
        <TextBlock.Text>This text uses a gradient.</TextBlock.Text>
        <TextBlock.Foreground>
          <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
            <GradientStop Color="Yellow" Offset="0.0" />
            <GradientStop Color="Red" Offset="0.25" />
            <GradientStop Color="Blue" Offset="0.75" />
            <GradientStop Color="LimeGreen" Offset="1.0" />
          </LinearGradientBrush>
        </TextBlock.Foreground>
      </TextBlock>
  </Canvas>
  
</UserControl>

   
    
    
    
  








Related examples in the same category

1.Implements the x:Name Attribute to a TextBlock and Button ElementImplements the x:Name Attribute to a TextBlock and Button Element
2.Creating a TextBlockCreating a TextBlock
3.To specify if the text should wrap to the next line if it is wider than the Width propertyTo specify if the text should wrap to the next line if it is wider than the Width property
4.Bind data to TextBlock
5.Implements a TextBlock to Display Key Data Captured from a TextBox ControlImplements a TextBlock to Display Key Data Captured from a TextBox Control
6.Scaled textScaled text
7.skewed textskewed text
8.TextBlock wrapping exampleTextBlock wrapping example
9.TextBlock alignment exampleTextBlock alignment example
10.TextBlock formatting exampleTextBlock formatting example
11.Animates the text block's colorAnimates the text block's color
12.Animates the text block's opacity(fading text)Animates the text block's opacity(fading text)
13.Animates the text block's widthAnimates the text block's width
14.Default underline decorationDefault underline decoration
15.Default baseline decoration
16.Default overline decoration
17.TextBlock VerticalAlignment
18.Add TextBlock into a GridAdd TextBlock into a Grid
19.Use RenderTransform to transform a TextBlockUse RenderTransform to transform a TextBlock
20.Set Margins for TextBlock in Grid ResourceSet Margins for TextBlock in Grid Resource
21.Set TextWrapping to True for TextBlockSet TextWrapping to True for TextBlock
22.Set Text value for TextBlockSet Text value for TextBlock
23.Set Foreground color for TextBlockSet Foreground color for TextBlock
24.Add Border to TextBlockAdd Border to TextBlock
25.TextBlock with DropShadowEffectTextBlock with DropShadowEffect
26.A basic TextBlock in actionA basic TextBlock in action
27.A TextBlock with Inline elementsA TextBlock with Inline elements
28.Setting the Foreground of a TextBlock at design timeSetting the Foreground of a TextBlock at design time
29.Underlining text in a TextBlock.Underlining text in a TextBlock.
30.Wrapping text within a TextBlockWrapping text within a TextBlock
31.Moving a TextBlock 5 pixels at a time by using the GetValue and SetValue methodsMoving a TextBlock 5 pixels at a time by using the GetValue and SetValue methods
32.To display a paragraph of text, you can use the TextBlock elementTo display a paragraph of text, you can use the TextBlock element
33.To introduce additional paragraphs, you can use the LineBreak element:To introduce additional paragraphs, you can use the LineBreak element:
34.Use Line break to add new line to TextBlockUse Line break to add new line to TextBlock
35.Use Run to control the font style for TextBlockUse Run to control the font style for TextBlock
36.Set current time to TextBlockSet current time to TextBlock
37.A basic TextBlock using the Canvas element Left and Top attached propertiesA basic TextBlock using the Canvas element Left and Top attached properties
38.The effects of the Padding property on a TextBlockThe effects of the Padding property on a TextBlock
39.Adding a rounded rectangle background to a TextBlock elementAdding a rounded rectangle background to a TextBlock element
40.Reference static resource for TextBlockReference static resource for TextBlock
41.Set font size and font family for TextBlock
42.Set foreground color to green for TextBlockSet foreground color to green for TextBlock
43.Zoom a TextBlockZoom a TextBlock
44.Put Button and TextBlock to CanvasPut Button and TextBlock to Canvas
45.Put Run block to TextBlockPut Run block to TextBlock
46.Inherited formattingInherited formatting
47.Gradient textGradient text