Alessandro Del Sole's Blog

/* A programming space about Microsoft® .NET® */
posts - 159, comments - 0, trackbacks - 0

My Links


Your host

This is me! This space is about Microsoft® .NET® and Microsoft® Visual Basic development. Enjoy! :-)

These postings are provided 'AS IS' for entertainment purposes only with absolutely no warranty expressed or implied and confer no rights.

Microsoft MVP

My MVP Profile

I'm a VB!

Watch my interview in Seattle

My new book on VB 2015!

Pre-order VB 2015 Unleashed Pre-order my new book "Visual Basic 2015 Unleashed". Click for more info!

My new book on LightSwitch!

Visual Studio LightSwitch Unleashed My book "Visual Studio LightSwitch Unleashed" is available. Click the cover!

Your visits

Follow me on Twitter!

CodePlex download Download my open-source projects from CodePlex!

Article Categories


Post Categories

.NET Framework


Help Authoring

Microsoft & MSDN

Setup & Deployment

Visual Basic 2005/2008/2010

Text animation in LightSwitch

As you might know, in LightSwitch 2012 you can now add text labels that are not data-bound, which is something you could not do in the previous version except if using some tricks.

So you basically select the Add Text command in a screen:

Then you specify the text to be displayed:

Such a label is shown as Normal text but in the properties you can change this behavior by selecting a different formatting such as Warning, Note, etc.

Behind the scenes it is a TextBlock control from Silverlight, so you can definitely create nice animations so that your text message is more appealing, e.g. like in a Welcome screen.

So you can create an animation in code, through a Storyboard and a ColorAnimation that you apply to the Foreground property, of course after you get the instance of the TextBlock. Translating in code:

        Private Sub Search_Created()

            ' Find the control

            Dim newsText = Me.FindControl("TextNews")


            AddHandler newsText.ControlAvailable, Sub(sender, e)

                                                      'Get the istance

                                                      Dim block = CType(e.Control, TextBlock)

                                                      'Set a different color, if you like

                                                      block.Foreground = New SolidColorBrush(Colors.Blue)


                                                      'Create an animation

                                                      Dim sb As New Storyboard

                                                      Dim colorAnim As New ColorAnimation

                                                      colorAnim.AutoReverse = True

                                                      colorAnim.RepeatBehavior = RepeatBehavior.Forever

                                                      colorAnim.From = Colors.Blue

                                                      colorAnim.To = Colors.Orange

                                                      colorAnim.Duration = TimeSpan.FromSeconds(1)


                                                      'Apply the animation

                                                      Storyboard.SetTarget(colorAnim, block.Foreground)

                                                      Storyboard.SetTargetProperty(colorAnim, New PropertyPath("Color"))



                                                  End Sub


        End Sub

You can certainly change animation properties as you like more, so you can choose different colors or a different duration. When you open the screen that contains the aforementioned label, you will see how it is animated. Sweet


Print | posted on venerdì 12 ottobre 2012 14:57 | Filed Under [ Visual Studio LightSwitch ]


No comments posted yet.

Post Comment

Please add 6 and 8 and type the answer here:

Powered by:
Powered By Subtext Powered By ASP.NET