You are previewing Silverlight™ 4 For Dummies®.
O'Reilly logo
Silverlight™ 4 For Dummies®

Book Description

The fun and easy guide for building Silverlight 4 applications!

Silverlight is a Web browser plugin that enables functions such as animation, streaming media, vector graphics, and audio-video playback that characterize rich Internet applications. It only requires a simple download, after which most end-users are not even aware that it's running. This helpful guide covers everything you need to know in order to start creating applications in Silverlight 4 and then moves on to key topics such as controls, data binding, skinning, using Visual Studio tools, and more.

Whether you have just the most basic programming skills and are interested in learning to develop Silverlight apps or you are an experienced developer looking for an understandable guide on the newest version of Silverlight, Microsoft Silverlight 4 For Dummies is ideal for a wide audience.

  • The Silverlight plugin enables animation, streaming media, vector graphics, and audio-video playback

  • Shows you how to create applications in Silverlight 4

  • Covers important Silverlight topics including controls, data binding, skinning, animations, and more

  • Discusses how to best use the offering of tools from Visual Studio

Get enlightened and start creating Silverlight 4 applications with this book by your side.

Table of Contents

  1. Copyright
  2. About the Authors
  3. Acknowledgements
  4. Publisher's Acknowledgments
  5. Introduction
    1. What's in This Book
    2. Foolish Assumptions
    3. How This Book Is Organized
      1. Part I: Illuminating Silverlight
      2. Part II: Managing Your Silverlight Controls
      3. Part III: Connecting with Data
      4. Part IV: The Part of Tens
    4. Conventions Used in This Book
    5. Icons Used in This Book
  6. I. Illuminating Silverlight
    1. 1. Adding Silverlight to Your Web Development Toolkit
      1. 1.1. Obtaining and Running Silverlight
      2. 1.2. Checking Out Some Silverlight-Enhanced Sites
      3. 1.3. Grasping the Potential of Silverlight
      4. 1.4. Hosting a Silverlight Application in a Web Page
      5. 1.5. All the Stuff You Need to Create Silverlight Applications
        1. 1.5.1. Visual Studio
        2. 1.5.2. Silverlight Tools for Visual Studio
        3. 1.5.3. Expression Blend
        4. 1.5.4. Silverlight Toolkit
        5. 1.5.5. WCF RIA Services
        6. 1.5.6. Deep Zoom Composer
      6. 1.6. Creating Rich User Experiences in Silverlight
      7. 1.7. Silverlight Plays Well with Others
      8. 1.8. Silverlight Has More to Offer Than Just a Pretty Face
    2. 2. Getting Started in Silverlight
      1. 2.1. Getting Started in Silverlight with Expression Blend
        1. 2.1.1. Exploring the Expression Blend interface
        2. 2.1.2. Menu bar
        3. 2.1.3. Artboard
        4. 2.1.4. Tools panel
        5. 2.1.5. Workspace panels
        6. 2.1.6. Adding a user interface element to the page
      2. 2.2. Introducing the Basics of the Extensible Application Markup Language
        1. 2.2.1. Digging deeper into XAML
        2. 2.2.2. Understanding elements and properties by category
      3. 2.3. Firing Up Visual Studio to Create a Silverlight Application
        1. 2.3.1. Exploring Visual Studio
        2. 2.3.2. Creating the Hello, World application
        3. 2.3.3. Exploring the Solution Explorer
        4. 2.3.4. Specifying the startup file for the application
        5. 2.3.5. Understanding other files involved in the solution
        6. 2.3.6. Hosting the Silverlight application
      4. 2.4. Using Expression Blend and Visual Studio in Tandem
    3. 3. Enhancing the User Interface
      1. 3.1. Getting to Know the Properties Panel
        1. 3.1.1. Setting a property for an object
        2. 3.1.2. Getting to know the Properties panel better
      2. 3.2. Drawing Shapes on the Artboard
        1. 3.2.1. Drawing with ready-made shapes
        2. 3.2.2. Drawing freehand
          1. 3.2.2.1. The Pen tool
          2. 3.2.2.2. The Pencil tool
        3. 3.2.3. Understanding the XAML for shapes
      3. 3.3. Shaping, Sizing, and Positioning Your Object
        1. 3.3.1. Getting your object into shape using your mouse
        2. 3.3.2. Reshaping and sizing an object using the Properties panel
        3. 3.3.3. Rounding the corners of a Rectangle object
      4. 3.4. Rotating, Projecting in 3-D, and Doing Other Funky Things with Shapes
        1. 3.4.1. Rotating a rectangle or other shape
        2. 3.4.2. Skewing an object
        3. 3.4.3. Applying 3-D Perspective transformations
      5. 3.5. Painting Colors with Brushes in the Properties panel
        1. 3.5.1. Filling an object with color
        2. 3.5.2. Using the Eyedropper tool
        3. 3.5.3. Mixing colors
        4. 3.5.4. Applying gradients for color transitions
        5. 3.5.5. Using the Gradient tool instead of setting gradients through the Properties panel
        6. 3.5.6. Manipulating gradients further with the Brush Transform tool
        7. 3.5.7. Adding special effects
      6. 3.6. Playing Around with Some Special Effects
      7. 3.7. Adding Video and Audio to Your Pages
        1. 3.7.1. Playing video and audio files
        2. 3.7.2. Creating a video brush
        3. 3.7.3. Displaying video from your Webcam
        4. 3.7.4. Selecting the default webcam and microphone for your application
  7. II. Managing Your Silverlight Controls
    1. 4. Working with Controls for UI Interactions
      1. 4.1. Exploring the Text-Related Tools
        1. 4.1.1. Displaying text with TextBlock
        2. 4.1.2. Using the TextBox and PasswordBox to get input from the user
        3. 4.1.3. Accessing TextBox values in XAML markup
      2. 4.2. Using Buttons in Your Application
        1. 4.2.1. Setting the content of a button
        2. 4.2.2. Adding an image as content for a Button
      3. 4.3. Jumping to Another Web page Using HyperlinkButton
      4. 4.4. Using RadioButtons to Present Options
      5. 4.5. Using the ListBox and ComboBox to present a large number of options
        1. 4.5.1. Creating a list box
        2. 4.5.2. Creating a combo box
      6. 4.6. Entering Rich Text into a RichTextBox Control
        1. 4.6.1. Understanding the XAML behind RichTextBox
        2. 4.6.2. Formatting text at runtime
    2. 5. Laying Out Controls
      1. 5.1. Understanding Layout Containers
        1. 5.1.1. The root container
        2. 5.1.2. Manipulating properties that control layout
        3. 5.1.3. Aligning controls to one side
        4. 5.1.4. Setting the Height and Width of a UserControl at design time
        5. 5.1.5. Clearing margins of an element from the Artboard
      2. 5.2. Laying Out Controls in Rows and Columns
        1. 5.2.1. Setting up rows and columns
        2. 5.2.2. Adding controls to the rows and columns
        3. 5.2.3. Understanding the XAML
        4. 5.2.4. Changing row heights and column widths on the Artboard
      3. 5.3. Stacking Controls Horizontally and Vertically
        1. 5.3.1. Adding controls to a StackPanel
        2. 5.3.2. Converting a Grid to a StackPanel
        3. 5.3.3. Understanding the XAML for a StackPanel
      4. 5.4. Wrapping Controls
      5. 5.5. Arranging Controls by Absolute Positioning Using the Canvas Control
      6. 5.6. Using the ScrollViewer to Scroll Through the Contents
      7. 5.7. Using the Viewbox to Fit the Contents Snugly
      8. 5.8. Grouping Controls into a Tabbed Page
      9. 5.9. Docking Controls
    3. 6. Styling and Skinning Controls
      1. 6.1. Applying Styles to Controls
        1. 6.1.1. Creating default styles for a control
        2. 6.1.2. Creating named styles for controls
        3. 6.1.3. Understanding the Style property
        4. 6.1.4. Understanding the XAML behind Style resources
        5. 6.1.5. Understanding styles as resources in the Resources panel
        6. 6.1.6. Applying styles to existing elements
          1. 6.1.6.1. Applying a style from the Resources panel
          2. 6.1.6.2. Applying a style from the Properties panel
        7. 6.1.7. Creating controls with existing styles
        8. 6.1.8. Creating new styles based on existing styles
      2. 6.2. Skinning a Control
        1. 6.2.1. Editing the template visually
        2. 6.2.2. Specifying state
        3. 6.2.3. Binding values in the template
        4. 6.2.4. Applying skins to existing controls
      3. 6.3. Using Themes to Change the Look of All Controls
    4. 7. Creating Your Own Controls
      1. 7.1. Grouping Controls to Create a UserControl
        1. 7.1.1. An example of creating an Address UserControl
        2. 7.1.2. Reusing the User control
        3. 7.1.3. Creating properties for your UserControl
      2. 7.2. Creating a Smiley Custom Control
        1. 7.2.1. Creating a SmileyUserControl
        2. 7.2.2. Adding states to SmileyUserControl
        3. 7.2.3. Testing the UserControl and switching the states
        4. 7.2.4. Creating the custom control
        5. 7.2.5. Using the custom control
        6. 7.2.6. Adding events to your control
      3. 7.3. Controlling the Behavior of Controls without Writing Code
    5. 8. Creating Animations in Silverlight
      1. 8.1. Creating a Simple Bouncing Ball Animation
        1. 8.1.1. Create the ball and set the timeline in motion
        2. 8.1.2. Switching to the Animation workspace
        3. 8.1.3. Animating the ball
        4. 8.1.4. Understanding the XAML behind the animation
          1. 8.1.4.1. Simple animation
          2. 8.1.4.2. Keyframe animation
      2. 8.2. Running the Animations You Create
        1. 8.2.1. Controlling animations from code
          1. 8.2.1.1. AutoReverse property
          2. 8.2.1.2. Completed event
          3. 8.2.1.3. RepeatBehavior property
        2. 8.2.2. Easing the animation
        3. 8.2.3. Understanding the different kinds of Easing functions
        4. 8.2.4. Easing using KeySplines
      3. 8.3. Animating States of Controls
    6. 9. Updating Data the Easy Way with Data Binding
      1. 9.1. Binding Controls to Each Other
      2. 9.2. Binding to a Data Object
        1. 9.2.1. Creating a user control for data binding
        2. 9.2.2. Data bind the controls in the UserControl to a property name
        3. 9.2.3. Create a data class that can be databound
        4. 9.2.4. Binding the data object to the control
        5. 9.2.5. Automatically updating changes to the data
        6. 9.2.6. Converting data while binding
      3. 9.3. Binding to Sample Data
        1. 9.3.1. Creating sample data
        2. 9.3.2. Binding a DataGrid to the sample data
        3. 9.3.3. Creating a Master-Detail view
        4. 9.3.4. Fooling around with the sample data
  8. III. Connecting with Data
    1. 10. Accessing Data in Silverlight
      1. 10.1. Downloading Files to Your Silverlight Application
        1. 10.1.1. Downloading files using the WebClient class
        2. 10.1.2. Using WebClient to include a progress bar with large downloads
        3. 10.1.3. Using the HTTPWebRequest class
      2. 10.2. Talking to Web Services
        1. 10.2.1. Accessing Web services that allow cross-domain exchanges
        2. 10.2.2. Programming against a Web service that has a WSDL
        3. 10.2.3. Creating your own WSDL Web service
      3. 10.3. Understanding Cross-Domain Security
        1. 10.3.1. Creating a cross-domain policy file
        2. 10.3.2. Accessing a Web service without a cross-domain policy file
        3. 10.3.3. Using the workaround: An example
      4. 10.4. Authenticating Users
    2. 11. Using WCF Data Services to Store and Manage Data
      1. 11.1. Getting Started with WCF Data Services
      2. 11.2. What, Exactly, Is WCF Data Services?
      3. 11.3. Creating a WCF Data Service
        1. 11.3.1. Creating the database
          1. 11.3.1.1. Creating the database
          2. 11.3.1.2. Adding the tables
          3. 11.3.1.3. Create the relationship between the tables
        2. 11.3.2. Adding the ADO.NET Entity Framework
        3. 11.3.3. Adding the WCF Data Service
      4. 11.4. Using the WCF Data Service in a Silverlight Application
        1. 11.4.1. Generating the proxy classes in the Silverlight application
        2. 11.4.2. Reading data from the database
        3. 11.4.3. Updating data in the database
        4. 11.4.4. Adding new items to the database
        5. 11.4.5. Deleting entities from the database
      5. 11.5. Handling Data Concurrency
      6. 11.6. Using Query and Change Interceptors to Control Data Querying and Updates
        1. 11.6.1. Controlling server-side queries with query interceptor
        2. 11.6.2. Enforcing rules using change interceptors
      7. 11.7. Controlling Access to Entity Sets
    3. 12. Using WCF RIA Services in Silverlight
      1. 12.1. Getting Started with WCF RIA Services
      2. 12.2. Authenticating Your Users
        1. 12.2.1. Authenticating users with the Business Application template
        2. 12.2.2. Understanding the client side of the Business Application template
        3. 12.2.3. Investigating the server side of the Business Application template
        4. 12.2.4. Understanding how the template files work together
      3. 12.3. Creating a Custom Authentication System
        1. 12.3.1. Implementing custom user validation logic
        2. 12.3.2. Returning a custom user object to the Silverlight application
    4. 13. Accessing Data with WCF RIA Services
      1. 13.1. Creating the Domain Data Service
        1. 13.1.1. Understanding the generated files
        2. 13.1.2. Creating the user interface
        3. 13.1.3. Retrieving the data
        4. 13.1.4. Updating your data
      2. 13.2. Writing Your Own Service Methods — LINQ to Entity Framework
        1. 13.2.1. A common mistake (Psst — This won't work!)
        2. 13.2.2. This, on the other hand, DOES work
      3. 13.3. Writing Your Own Service Methods — LINQ to SQL
      4. 13.4. Validating Data on the Client and Server Sides
        1. 13.4.1. Adding validation attributes
        2. 13.4.2. Using a DataForm for great validation
      5. 13.5. Securing Your WCF RIA Service
  9. IV. The Part of Tens
    1. 14. Ten Cool Controls for Collecting and Displaying Data
      1. 14.1. ListBox
      2. 14.2. DataGrid
      3. 14.3. DataForm
      4. 14.4. Expander
      5. 14.5. Chart
      6. 14.6. DatePicker
      7. 14.7. ProgressBar
      8. 14.8. TreeView
      9. 14.9. Rating
      10. 14.10. AutoCompleteBox
    2. 15. Ten Ways to Get More Out of Silverlight
      1. 15.1. Using SketchFlow to Prototype Your Application
      2. 15.2. Using Deep Zoom Composer
      3. 15.3. Creating Designs Using Expression Design
      4. 15.4. Importing Designs from Other Applications
      5. 15.5. Creating Your Own Behaviors
      6. 15.6. Running Silverlight Out of the Browser
      7. 15.7. Calling Silverlight code via JavaScript
        1. 15.7.1. Create a scriptable method
        2. 15.7.2. Create and register the object
        3. 15.7.3. Call the ScriptableMember function
      8. 15.8. Accessing HTML from Silverlight
        1. 15.8.1. Using the WebBrowser control
        2. 15.8.2. Using the DOM to access HTML
      9. 15.9. Storing Data Locally in the Client
    3. 16. Ten Handy Tips for Writing Silverlight Applications
      1. 16.1. Resources about Silverlight Beyond This Book
      2. 16.2. Ten Handy Expression Blend Shortcuts
      3. 16.3. Ten Handy Visual Studio Shortcuts
      4. 16.4. Debugging Silverlight Applications
      5. 16.5. Looking Out for Performance Pitfalls
      6. 16.6. Building for Accessibility
      7. 16.7. Internationalization and Localization
      8. 16.8. Build Composite Applications Using Prism
      9. 16.9. Use the Model-View-ViewModel (MVVM) Pattern to Manage Large Applications
      10. 16.10. Handy Tools