In this article we’ll see how to create a marquee control in WPF or Silverlight application using Expression Blend.
Marquee control is used for scrolling piece of text or image displayed either horizontally across or vertically down on your web site page or application depending on the settings.
Following is a sample marquee
This is a sample marquee, lets see how you can created it using expression blend.
Assumptions: Before proceeding further i’ll assume that you guys have create a black WPF application in expression Blend.
Now Let’s see how we can create a marquee control in our application.
- Draw a rectangle in your application at the place where you want to create the marquee as shown below:
- Place a TextBlock Control on your rectangle. (Number of Text Block Depends on how many news/information you want to scroll on your application. In my Case i’m using 2 TextBlock Controls) as shown below:
- Now its time to scroll your news/information. For this you should know StoryBoarding in expression blend. If you are new to expression blend you can read this article ( StoryBoarding in Expression Blend ).
- Create a new story Board in expression blend and give it some name as shown below:
- Now select both the TextBlock Controls and add a Keyframe in your story board as shown below:
- Now at some point suppose its 3 ns in your story board add another keyframe and move the textblock controls forward as shown below:
- Now if your play the storyboard you’ll see the TextBlocks scrolling but they’ll scroll once. To move them continuously we need to play the storyboard forever. Lets see how we can do this:
See the xaml code of your MainPage.xaml and find your storyboard (in my case the name of my storyboard is marquee).
- After finding the story board just add the RepeatBehavior=”Forever” as shown below:
Now build the project and run it, you will see a marquee with scrolling text on it in your application. That’s all if you have any kind of trouble free feel to ask me.