Geeks With Blogs

News
Michael Crump Microsoft MVP, INETA Community Champion and XAML Advocate.

I recently needed to create a scrolling text in a WPF application. After I did some digging, I found it and thought that I would post here to share. I’ve added my own touches to it, so the original source has been modified.

<TextBlock Grid.Row="2" FontSize="22" Name="txtScrolling">
<TextBlock.RenderTransform>
  <TranslateTransform x:Name="translate" />
    </TextBlock.RenderTransform>
      <TextBlock.Triggers>
        <EventTrigger RoutedEvent="FrameworkElement.Loaded">
            <BeginStoryboard>
                <Storyboard RepeatBehavior="Forever">
                    <DoubleAnimation 
                        From="1200" To="-1200" 
                        Storyboard.TargetName="translate" 
                        Storyboard.TargetProperty="X"
                        Duration="0:0:9" />
                </Storyboard>
            </BeginStoryboard>
        </EventTrigger>
    </TextBlock.Triggers>
    This is the Text to Scroll
</TextBlock>

Image the text below is scrolling to get an idea what the XAML does. =)

image

Posted on Thursday, July 8, 2010 4:34 PM WPF | Back to top

Copyright © mbcrump | Powered by: GeeksWithBlogs.net