pro silverlight 4 in c#

913 1.7K 0
pro silverlight 4 in c#

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

MacDonald Companion eBook Available this print for content only—size & color not accurate   CYAN   MAGENTA   YELLOW   BLACK   PANTONE 123 C BOOKS FOR PROFESSIONALS BY PROFESSIONALS ® Pro Silverlight 4 in C# Dear Reader, Silverlight is a revolutionary browser plug-in that allows developers to create rich client applications that run inside the browser. Like Adobe Flash, Silverlight supports event handling, two-dimensional drawing, video playback, network- ing, and animation. Unlike Flash, Silverlight is tailored to .NET developers and supports pure C# code. The most exciting part of Silverlight is its cross-platform muscle. Unlike ordinary .NET applications, Silverlight applications run seamlessly in non- Microsoft browsers (like Firefox, Safari, and Chrome) and on non-Microsoft platforms (like Mac OS X). Essentially, Silverlight is a scaled-down, browser- hosted version of .NET—and that’s made it the most hotly anticipated technol- ogy that Microsoft has released in years. In this book, you’ll master Silverlight from the ground up. No Silverlight experience is required—but if you’ve worked with Silverlight 3, you’ll appreci- ate the “What’s New” boxes that point out new features at the start of every chapter. By the end of this book, you’ll have a solid understanding of the com- plete Silverlight platform, and you’ll be able to build anything from a slick busi- ness front-end to a browser-based game. Welcome aboard! Matthew MacDonald MCSD, Microsoft Silverlight MVP Matthew MacDonald, author of Pro WPF in C# 2010 Pro ASP.NET 4 in C# 2010 (with Adam Freeman and Mario Szpuszta) Beginning ASP.NET 4 in C# 2010 Your Brain: The Missing Manual US $49.99 Shelve in Web Design/General User level: Intermediate - Advanced THE APRESS ROADMAP Pro Telerik ASP.NET and Silverlight Controls Pro Business Applications with Silverlight 4 Pro Silverlight 4 in C# Pro WPF in C# 2010 Introducing Silverlight 4 Beginning Silverlight 4 in C# www.apress.com SOURCE CODE ONLINE Companion eBook See last page for details on $10 eBook version ISBN 978-1-4302-2979-7 9 781430 229797 5 49 9 9 Silverlight 4 in C# Full Color Inside Pro 7 x 9.125 spine = 2.09375" 912 page count THE EXPERT’S VOICE ®  IN SILVERLIGHT Pro Silverlight 4 in C# Matthew MacDonald Create cross-platform .NET applications for the browser Full Color Inside www.it-ebooks.info www.it-ebooks.info Pro Silverlight 4 in C# ■ ■ ■ Matthew MacDonald www.it-ebooks.info Pro Silverlight 4 in C# Copyright © 2010 by Matthew MacDonald All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright the publisher. ISBN-13 (pbk): 978-1-4302-2529-2979-7 ISBN-13 (electronic): 978-1-4302-2980-3 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. President and Publisher: Paul Manning Lead Editor: Ewan Buckingham Technical Reviewer: Fabio Claudio Ferracchiati Editorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell, Jonathan Gennick, Jonathan Hassell, Michelle Lowman, Matthew Moodie, Duncan Parkes, Jeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Coordinating Editors: Anne Collett and Debra Kelly Copy Editor: Kim Wimpsett Compositor: Mary Sudul Indexer: BIM Indexing & Proofreading Services Artist: April Milne Cover Designer: Anna Ishchenko Distributed to the book trade worldwide by Springer Science+Business Media, LLC., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. For information on translations, please e-mail rights@apress.com, or visit www.apress.com. Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at www.apress.com/info/bulksales. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. www.it-ebooks.info For my family www.it-ebooks.info www.it-ebooks.info ■ CONTENTS v Contents at a Glance ■ Contents vi ■ About the Author xxii ■ About the Technical Reviewer xxiii ■ Acknowledgments xxiv ■ Introduction xxv ■ Chapter 1: Introducing Silverlight 1 ■ Chapter 2: XAML 33 ■ Chapter 3: Layout 61 ■ Chapter 4: Dependency Properties and Routed Events 107 ■ Chapter 5: Elements 141 ■ Chapter 6: The Application Model 197 ■ Chapter 7: Navigation 227 ■ Chapter 8: Shapes and Geometries 259 ■ Chapter 9: Brushes, Transforms, and Bitmaps 295 ■ Chapter 10: Animation 339 ■ Chapter 11: Sound, Video, and Deep Zoom 399 ■ Chapter 12: Styles and Behaviors 447 ■ Chapter 13: Templates and Custom Controls 471 ■ Chapter 14: Browser Integration 513 ■ Chapter 15: ASP.NET Web Services 539 ■ Chapter 16: Data Binding 569 ■ Chapter 17: Data Controls 619 ■ Chapter 18: File Access 669 ■ Chapter 19: Multithreading 695 ■ Chapter 20: Networking 717 ■ Chapter 21: Out-of-Browser Applications 767 ■ Index 809 www.it-ebooks.info ■ CONTENTS vi Contents ■ Contents at a Glance v ■ About the Author xxii ■ About the Technical Reviewer xxiii ■ Acknowledgments xxiv ■ Introduction xxv ■ Chapter 1: Introducing Silverlight 1 Silverlight Design Tools 1 Visual Studio vs. Expression Blend 1 Understanding Silverlight Websites 2 Creating a Stand-Alone Silverlight Project 3 Creating a Simple Silverlight Page 6 Adding Event-Handling Code 8 Testing a Silverlight Application 10 Creating an ASP.NET-Hosted Silverlight Project 12 ASP.NET Controls That Render Silverlight Content 15 Mixing ASP.NET Controls and Silverlight Content 16 Silverlight Compilation and Deployment 16 Compiling a Silverlight Application 16 Deploying a Silverlight Application 18 Silverlight Core Assemblies 20 Silverlight Add-on Assemblies 21 Assembly Caching 22 The HTML Entry Page 24 Sizing the Silverlight Content Region 26 Silverlight Parameters 26 Alternative Content 28 Creating a Friendly Install Experience 28 www.it-ebooks.info ■ CONTENTS vii The Mark of the Web 30 The Last Word 31 ■ Chapter 2: XAML 33 XAML Basics 34 XAML Namespaces 35 The Code-Behind Class 38 Properties and Events in XAML 39 Simple Properties and Type Converters 41 Complex Properties 42 Attached Properties 44 Nesting Elements 45 Events 48 The Full Eight Ball Example 49 XAML Resources 50 The Resources Collection 50 The Hierarchy of Resources 51 Accessing Resources in Code 53 Organizing Resources with Resource Dictionaries 54 Element-to-Element Binding 56 One-Way Binding 56 Two-Way Binding 57 The Last Word 59 ■ Chapter 3: Layout 61 The Layout Containers 61 The Panel Background 63 Borders 65 Simple Layout with the StackPanel 66 Layout Properties 68 Alignment 69 Margins 70 Minimum, Maximum, and Explicit Sizes 72 The WrapPanel and DockPanel 74 The WrapPanel 74 The DockPanel 75 www.it-ebooks.info ■ CONTENTS viii The Grid 77 Fine-Tuning Rows and Columns 79 Nesting Layout Containers 80 Spanning Rows and Columns 82 The GridSplitter 83 Coordinate-Based Layout with the Canvas 86 Layering with ZIndex 88 Clipping 88 Custom Layout Containers 90 The Two-Step Layout Process 90 The UniformGrid 93 Sizing Pages 98 Scrolling with the ScrollViewer 100 Scaling with the Viewbox 102 Full-Screen Mode 104 The Last Word 106 ■ Chapter 4: Dependency Properties and Routed Events 107 Dependency Properties 107 Defining and Registering a Dependency Property 108 Dynamic Value Resolution 110 Attached Properties 111 The WrapBreakPanel Example 112 Routed Events 115 The Core Element Events 115 Event Bubbling 118 Handled (Suppressed) Events 120 An Event Bubbling Example 120 Mouse Handling 123 Right-Clicks 123 Mouse Movements 124 The Mouse Wheel 124 Capturing the Mouse 126 A Mouse Event Example 127 Mouse Cursors 130 www.it-ebooks.info [...]... Behaviors 44 7 Styles 44 7 Defining a Style 44 8 Applying a Style 44 9 xiv www.it-ebooks.info ■ CONTENTS Dynamic Styles 45 0 Style Inheritance 45 0 Organizing Styles 45 2 Automatically Applying Styles by Type 45 2 Behaviors 45 4 Getting Support for Behaviors 45 4 Triggers and Actions... 40 2 Changing Volume, Balance, and Position 40 3 Playing Video 40 7 Client-Side Playlists 40 8 Server-Side Playlists 40 8 Progressive Downloading and Streaming 40 9 Adaptive Streaming 41 1 Advanced Video Playback 41 2 Video Encoding 41 2 Encoding in Expression Encoder 41 3 Markers 41 5... xxi www.it-ebooks.info ■ CONTENTS About the Author ■ Matthew MacDonald is an author, educator, and Microsoft MVP for Silverlight He’s the author of more than a dozen books about NET programming, including Pro WPF in C# 2010, Pro ASP.NET 4 in C# 2010, and Beginning ASP.NET in C# 2010 He’s also the author of Your Brain: The Missing Manual (Pogue Press, 2008), a popular look at getting the most from your... Actions 45 5 Creating a Behavior 46 5 Finding More Behaviors 46 8 The Last Word 47 0 ■ Chapter 13: Templates and Custom Controls 47 1 Template Basics 47 1 Creating a Template 47 2 Reusing Control Templates 47 3 The ContentPresenter 47 4 Template Bindings 47 5 Setting Templates Through... 47 6 Reusing Colors 47 8 The Parts and States Model 47 8 Understanding States with the Button Control 48 0 Showing a Focus Cue 48 4 Transitions 48 5 Understanding Parts with the Slider Control 49 0 Creating Templates for Custom Controls 49 4 Planning the FlipPanel Control 49 5 Creating the Solution 49 6... VideoBrush 42 0 Video Effects 42 1 Webcam and Microphone Input 42 7 Accessing a Capture Device 42 7 Basic Webcam Support 42 9 Recording Audio Snippets 43 2 Deep Zoom 43 6 Creating a Deep Zoom Image Set 43 8 Using a Deep Zoom Image Set in Silverlight 44 2 The Last Word 44 5 ■ Chapter 12: Styles... point, you can click the Get Microsoft Silverlight picture to be taken to Microsoft’s website, where you will be prompted to install the plug -in and then will be sent back to the original page On the bottom is the page you’ll see once the Silverlight plug -in is installed www.it-ebooks.info ■ INTRODUCTION Figure 1 Installing the Silverlight plug -in ■ Note At the time of this writing, Silverlight 4 is... that follow the introduction in each chapter They point out features that are new to Silverlight 4 so you can home in on its changes and enhancements BACKWARD COMPATIBILITY IN SILVERLIGHT 4 At this point, you might be wondering whether existing Silverlight 2 and Silverlight 3 applications can run on a computer that has only the latest version of the Silverlight plug -in (version 4) installed It’s a... example, to all the buttons in a window) This convenient feature makes it almost effortless to reskin an application Chapter 12 explains how automatic styles work Data-binding refinements: Silverlight 4 adds data-binding properties that allow you to handle null values and apply simple formatting with a minimum of work You’ll learn more in Chapter 16 xxx www.it-ebooks.info ■ INTRODUCTION • • File drag-and-drop:... Understanding Silverlight Animation 339 The Rules of Animation 340 Creating Simple Animations 341 The Animation Class 341 The Storyboard Class 342 Starting an Animation with an Event Trigger 343 Starting an Animation with Code 344 Configuring Animation Properties 345 Animation Lifetime 347 Simultaneous . Set in Silverlight 44 2 The Last Word 44 5 ■ Chapter 12: Styles and Behaviors 44 7 Styles 44 7 Defining a Style 44 8 Applying a Style 44 9 www.it-ebooks.info ■ CONTENTS xv Dynamic Styles 45 0. 978-1 -43 02-2979-7 9 78 143 0 229797 5 49 9 9 Silverlight 4 in C# Full Color Inside Pro 7 x 9.125 spine = 2.09375" 912 page count THE EXPERT’S VOICE ® IN SILVERLIGHT Pro Silverlight 4 in C# Matthew. Applications with Silverlight 4 Pro Silverlight 4 in C# Pro WPF in C# 2010 Introducing Silverlight 4 Beginning Silverlight 4 in C# www.apress.com SOURCE CODE ONLINE Companion eBook See last page for

Ngày đăng: 01/08/2014, 16:35

Từ khóa liên quan

Mục lục

  • Prelim

  • Contents at a Glance

  • Contents

  • About the Author

  • About the Technical Reviewer

  • Acknowledgments

  • Introduction

    • Understanding Silverlight

      • Silverlight System Requirements

      • Silverlight vs. Flash

      • Silverlight and WPF

      • The Evolution of Silverlight

      • About This Book

        • What You Need to Use This Book

        • The Silverlight Toolkit

        • Code Samples

        • Feedback

        • The Last Word

        • Introducing Silverlight

          • Silverlight Design Tools

            • Visual Studio vs. Expression Blend

            • Understanding Silverlight Websites

            • Creating a Stand-Alone Silverlight Project

            • Creating a Simple Silverlight Page

              • Adding Event-Handling Code

              • Testing a Silverlight Application

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan