Animates the text block's color : TextBlock « UI Controls « Silverlight






Animates the text block's color

Animates the text block's color
    

<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
        Name="MyChangingColorText"
        Margin="20" 
        Width="640" Height="100" FontSize="48" FontWeight="Bold">
        This is changing color text
        <TextBlock.Foreground>
          <SolidColorBrush x:Name="MySolidColorBrush" Color="Maroon" />
        </TextBlock.Foreground>

        <TextBlock.Triggers>
          <EventTrigger RoutedEvent="TextBlock.Loaded">
            <BeginStoryboard>
              <Storyboard>
                <ColorAnimation 
                  Storyboard.TargetName="MySolidColorBrush"
                  Storyboard.TargetProperty="Color"
                  From="Blue" To="Red" Duration="0:0:5"
                  AutoReverse="True" RepeatBehavior="Forever" />
              </Storyboard>
            </BeginStoryboard>
          </EventTrigger>
        </TextBlock.Triggers>
      </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 opacity(fading text)Animates the text block's opacity(fading text)
12.Animates the text block's widthAnimates the text block's width
13.Default underline decorationDefault underline decoration
14.Default baseline decoration
15.Default overline decoration
16.TextBlock VerticalAlignment
17.Add TextBlock into a GridAdd TextBlock into a Grid
18.Use RenderTransform to transform a TextBlockUse RenderTransform to transform a TextBlock
19.Set Margins for TextBlock in Grid ResourceSet Margins for TextBlock in Grid Resource
20.Set TextWrapping to True for TextBlockSet TextWrapping to True for TextBlock
21.Set Text value for TextBlockSet Text value for TextBlock
22.Set Foreground color for TextBlockSet Foreground color for TextBlock
23.Add Border to TextBlockAdd Border to TextBlock
24.TextBlock with DropShadowEffectTextBlock with DropShadowEffect
25.A basic TextBlock in actionA basic TextBlock in action
26.A TextBlock with Inline elementsA TextBlock with Inline elements
27.Setting the Foreground of a TextBlock at design timeSetting the Foreground of a TextBlock at design time
28.Underlining text in a TextBlock.Underlining text in a TextBlock.
29.Wrapping text within a TextBlockWrapping text within a TextBlock
30.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
31.To display a paragraph of text, you can use the TextBlock elementTo display a paragraph of text, you can use the TextBlock element
32.To introduce additional paragraphs, you can use the LineBreak element:To introduce additional paragraphs, you can use the LineBreak element:
33.Use Line break to add new line to TextBlockUse Line break to add new line to TextBlock
34.Use Run to control the font style for TextBlockUse Run to control the font style for TextBlock
35.Set current time to TextBlockSet current time to TextBlock
36.A basic TextBlock using the Canvas element Left and Top attached propertiesA basic TextBlock using the Canvas element Left and Top attached properties
37.The effects of the Padding property on a TextBlockThe effects of the Padding property on a TextBlock
38.Adding a rounded rectangle background to a TextBlock elementAdding a rounded rectangle background to a TextBlock element
39.Use a gradient to paint TextBlockUse a gradient to paint TextBlock
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