Book Image

Instant Silverlight 5 Animation

By : Nick Polyak
Book Image

Instant Silverlight 5 Animation

By: Nick Polyak

Overview of this book

Silverlight is a Web technology that allows you to create both large business applications and little ads for your web page. Silverlight's main advantage is the ability to create rich UIs easily. In this book we will show how to build animations for different types of Silverlight applications in order to create great user experience."Instant Silverlight 5 Animation" is a practical guide to creating great user experiences in Silverlight. This book will clear Silverlight/WPF concepts needed for creating animations as well as practical examples of creating animations that will help you become an efficient developer for creating animations with Silverlight.This book provides a number of hands on examples of creating Silverlight animations in order to improve the user experience whether you are building a Silverlight Business application or a Silverlight banner ad. We also talk about ways to integrate Silverlight animations with business logic quickly and in the least invasive way. This book can be of help to both beginners and advanced developers. It starts talking about Silverlight concepts like dependency/attached properties and bindings. Then it goes into nitty-gritty detail of creating different animations for different application types. We explain how to animate custom controls, page navigation, how to imitate animation of random processes like fire or moving clouds. We talk about creating 3-D animations and building banner ads for your web page. Every concept, we describe in this book, is supported by small, detailed and easy to understand samples.
Table of Contents (16 chapters)

Preface

What is Silverlight

Silverlight is a relatively new technology introduced by Microsoft in order to enable the developers to build multi-platform client GUI applications that can run within or outside of Internet browsers.

Why should I use Silverlight

Silverlight empowers developers with great new GUI capabilities, combined with revolutionary GUI coding concepts that came to Silverlight from WPF. While some think that HTML 5 gives the developers functionality that is almost as powerful as Silverlight, the programming model of HTML 5 is indisputably old, while the Silverlight/WPF programming model is ahead of that of any competing software.

Unlike the currently available versions of HTML, Silverlight is 98 percent multi-platform (between Windows and Macs) and its list of non multi-platform features is freely available. As long as you avoid using those features, any application you build for Windows is guaranteed to run on Mac.

Silverlight is close to being 100 percent multi-browser (if there are any features that do not perform the same on different browsers, I am not aware of them) and any application you write using Internet Explorer is guaranteed to run within Firefox on the same platform, while this might not be the case with HTML.

Silverlight has a very small footprint – in order to make Silverlight 5 run on your machine you need to download and install only a 6 MB package.

Silverlight makes it very easy to deploy your application via the Internet, whether it is a browser-based application or not.

Microsoft Phone uses Silverlight as its primary coding platform.

What is the downside of using Silverlight

Microsoft pedalled back on Silverlight as they decided that Silverlight might undermine their Windows platform. The Windows 8 platform uses many Silverlight concepts, but is strictly Windows oriented.

Apple does not allow plugins for their iPhone and iPad browsers, since plugins undermine their Apple store application model. Microsoft followed suit and Windows 8 browsers for tablets and phones will not support Silverlight as a browser plugin. To the best of my knowledge, Windows 8 tablets will continue to run Silverlight applications outside of browsers. The Windows 8 programing model, however, is very similar to Silverlight and it should be easy to convert your Silverlight application to Windows 8.

There is a lot of buzz around HTML 5 being able to do everything that Silverlight does, and, undeniably, the HTML 5 application will run on the platforms so far closed to Silverlight – iPads, iPhones, and Android systems. From my point of view, while HTML 5 is a great technology, it does not address the questions that have plagued the HTML/JavaScript technology from the outset – namely its programming paradigms are not strong enough to support coding complex business logic. Additionally, HTML 5 will not run on many of the existing desktop browsers, so if someone wants to build a website available to everyone they usually have to use HTML 4.

What this book covers

This book is about creating animations using Silverlight technology.

Chapter 1, Building Blocks of Animation, talks about the Silverlight concepts used for animation: dependency and attached properties, bindings, transforms, and storyboards.

Chapter 2, Animations in Business Logic Silverlight Applications, talks about using VisualStateManager for custom control animations and animation navigation transitions.

Chapter 3, Creating Animated Textures, talks about using Perlin noise for generating random processes such as clouds and fire.

Chapter 4, 3D Animations in Silverlight, talks about using Perspective Transform for simple 3D animations and also covers using a subset of the XNA functionality in Silverlight for more complex animations.

Chapter 5, Building an Animated Banner, talks about creating a Silverlight animated banner and integrating it into an HTML page.

What you need for this book

The following software should be installed in order for the reader to be able to run the samples:

  1. MS Visual Studio 2010 Professional (a trial version can be downloaded from http://www.microsoft.com/en-us/download/details.aspx?id=2890 and will run for a period of time without requiring the user to purchase a license).

  2. MS Visual Studio 2010 SP1 can be downloaded free from http://www.microsoft.com/en-us/download/details.aspx?id=23691. It should only be installed after the installation of Visual Studio.

  3. Silverlight 5 tools for Visual Studio 2010 SP1 can be downloaded free from http://www.microsoft.com/en-us/download/details.aspx?id=28358.

Who this book is for

We assume that the reader already has basic knowledge of Silverlight or WPF programming concepts. One should not use this book to learn Silverlight or WPF basics.

Notes on the samples

We recommend that you create and build all the samples from scratch, using the source code provided with the book just as a way to check your work.

WPF experts with no previous Silverlight experience might have difficulty creating, starting, and understanding Silverlight applications, so there is Appendix A, Creating and starting a Silverlight project, describing how to do it.

Silverlight only has a subset of WPF functionality, for example, it does not have data and property triggers, and its event triggers can only react to a loaded event. MS Expression Blend SDK provides functionality to mitigate these deficiencies, as well as many other exciting features. Expression Blend SDK DLLs are free and fully redistributable and are provided with the samples under the MSExpressionBlendSDKDll folder. Expression Blend SDK does not require Expression Blend (which we are not using anyways).

Follow the instructions within Appendix B, Changing the XAML formatting, if you want to format your XAML file to have each XML attribute on a separate line as we do in our sample code.

In order to format your C# code similar to the code in our samples, please install and use the snippets provided under the Snippets folder (which is part of the sample code that comes with the book). Information on installing and using snippets is available in Appendix C, Installing snippets, and Appendix D, Using snippets, respectively.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "We can include other contexts through the use of the include directive."

A block of code is set as follows:

public double RotationAngle
{
    get { return (double)GetValue(RotationAngleProperty); }
    set { SetValue(RotationAngleProperty, value); }
}

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes, for example, appear in the text like this: "You can start the browser displaying our Silverlight banner within that HTML page by right-clicking on the file within Solution Explorer and choosing View in Browser".

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title through the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website, or added to any list of existing errata, under the Errata section of that title.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.