Pro Business Applications with Silverlight 4

Similar documents
Pro Business Applications with Silverlight 4

Beginning Silverlight 5 in C #

Silverlight Recipes. A Problem-Solution Approach. Apress* Jit Ghosh and Rob Cameron

Beginning ASP.NET. 4.5 in C# Matthew MacDonald

Introduction. Part I: Silverlight Fundamentals for ASP.NET Developers 1

Pro XAML with C# From Design to Deployment on WPF, Windows Store, and Windows Phone. Buddy James. Lori Lalonde

"Charting the Course... MOC A Introduction to Web Development with Microsoft Visual Studio Course Summary

Apex TG India Pvt. Ltd.

Mastering LOB Development

--Microsoft-- --Windows Phone--

CHAPTER 1: INTRODUCING C# 3

Microsoft Visual Studio 2010

Acknowledgments Introduction. Part I: Programming Access Applications 1. Chapter 1: Overview of Programming for Access 3

10267A CS: Developing Web Applications Using Microsoft Visual Studio 2010

2310C VB - Developing Web Applications Using Microsoft Visual Studio 2008 Course Number: 2310C Course Length: 5 Days

Programming in C# for Experienced Programmers

Pro ASP.NET MVC 2 Framework

PART I: INTRODUCTION TO WINDOWS 8 APPLICATION DEVELOPMENT CHAPTER 1: A BRIEF HISTORY OF WINDOWS APPLICATION DEVELOPMENT 3

Developing Windows Applications with Microsoft Visual Studio 2010

COURSE OUTLINE: OD10267A Introduction to Web Development with Microsoft Visual Studio 2010

Fundamentals of XAML and Microsoft Expression Blend

10267 Introduction to Web Development with Microsoft Visual Studio 2010

DE Developing Windows Applications with Microsoft Visual Studio 2010

SECURED PROGRAMMING IN.NET DETAILED TRAINING CONTENT INDUSTRIAL TRAINING PROGRAM ( )

DEVELOPING WINDOWS APPLICATIONS WITH MICROSOFT VISUAL STUDIO 2010

ASP.NET 2.0 p. 1.NET Framework 2.0 p. 2 ASP.NET 2.0 p. 4 New Features p. 5 Special Folders Make Integration Easier p. 5 Security p.

DOT.NET MODULE 6: SILVERLIGHT

brief contents PART 1 INTRODUCING WINDOWS PHONE... 1 PART 2 CORE WINDOWS PHONE... 57

10264A CS: Developing Web Applications with Microsoft Visual Studio 2010

Introduction to Web Development with Microsoft Visual Studio 2010

Programming in C# (20483)

COPYRIGHTED MATERIAL. Contents. Part I: C# Fundamentals 1. Chapter 1: The.NET Framework 3. Chapter 2: Getting Started with Visual Studio

"Charting the Course to Your Success!" MOC B Programming in C# Course Summary

"Charting the Course... SharePoint 2007 Hands-On Labs Course Summary

20486-Developing ASP.NET MVC 4 Web Applications

IN PRACTICE. Daniele Bochicchio Stefano Mostarda Marco De Sanctis. Includes 106 practical techniques MANNING

Microsoft Silverlight 4 Business Application Development

DE Introduction to Web Development with Microsoft Visual Studio 2010

The course introduces many of the techniques and technologies employed by modern desktop and enterprise applications, including:

Open Source Library Developer & IT Pro

Course Description. Audience. Module Title : 20483B: Programming in C# Duration : 5 days. Course Outline :: 20483B ::

This module reviews the core syntax and features of the C# programming language. It also provides an introduction to the Visual Studio 2012 debugger.

Developing Windows Applications with Microsoft Visual Studio 2010

DOT NET SYLLABUS FOR 6 MONTHS

CHAPTER 1: GETTING STARTED WITH ASP.NET 4 1

20483BC: Programming in C#

Developing ASP.NET MVC 5 Web Applications. Course Outline

Beginning Silverlight 3

SharePoint 2010 Developer Core Skills Course Length: 5 days Price: $3,000

Developing ASP.NET MVC 5 Web Applications

ArtOfTest Inc. Automation Design Canvas 2.0 Beta Quick-Start Guide

Professional SharePoint 2010 Development

Developing Web Applications Using Microsoft Visual Studio 2008 SP1

Installing and Administering a Satellite Environment

Jim Jackson II Ian Gilman

Acknowledgments... xix

DE-2310 Developing Web Applications Using Microsoft Visual Studio 2008 SP1

NE Fundamentals of XAML and Microsoft Expression Blend

SHAREPOINT 2013 DEVELOPMENT

"Charting the Course... MOC A Developing Data Access Solutions with Microsoft Visual Studio Course Summary

Microsoft. Inside Microsoft. SharePoint Ted Pattison. Andrew Connell. Scot Hillier. David Mann

Telerik Corp. Test Studio Standalone & Visual Studio Plug-In Quick-Start Guide

Introduction to Web Development with Microsoft Visual Studio 2010

ASP.NET MVC Training

Windows Presentation Foundation Programming Using C#

Developing ASP.Net MVC 4 Web Application

HOMELESS INDIVIDUALS AND FAMILIES INFORMATION SYSTEM HIFIS 4.0 TECHNICAL ARCHITECTURE AND DEPLOYMENT REFERENCE

COURSE 20486B: DEVELOPING ASP.NET MVC 4 WEB APPLICATIONS

DEVELOPING WEB APPLICATIONS WITH MICROSOFT VISUAL STUDIO Course: 10264A; Duration: 5 Days; Instructor-led

"Charting the Course... MOC B Developing Microsoft SharePoint Server 2013 Core Solutions. Course Summary

20486: Developing ASP.NET MVC 4 Web Applications (5 Days)

Mastering VB.NET using Visual Studio 2010 Course Length: 5 days Price: $2,500

[MS10553]: Fundamentals of XAML and Microsoft Expression Blend

Developing ASP.NET MVC 5 Web Applications

Application Development

Developing Windows Applications with Microsoft Visual Studio 2010 (MS 10262)

Etanova Enterprise Solutions

Pro Windows 8.1. Development with. XAML and C# Jesse Liberty. Philip Japikse. Jon Galloway

Developing ASP.NET MVC 4 Web Applications

Microsoft Programming in C#

10262A VB: Developing Windows Applications with Microsoft Visual Studio 2010

Chapters and Appendix F are PDF documents posted online at the book s Companion Website (located at

Advanced WCF 4.0 .NET. Web Services. Contents for.net Professionals. Learn new and stay updated. Design Patterns, OOPS Principles, WCF, WPF, MVC &LINQ

"Charting the Course... MOC A: Developing with the SharePoint Framework. Course Summary

Configuring and Customizing the ArcGIS Viewer for Silverlight. Katy Dalton

Pro ODP.NET for Oracle. Database 11 g. Edmund Zehoo. Apress

Developing Rich Internet Applications Using Microsoft Silverlight 4

20486: Developing ASP.NET MVC 4 Web Applications

C# Programming: From Problem Analysis to Program Design. Fourth Edition

20486 Developing ASP.NET MVC 5 Web Applications

Managing. mashup of chapters from. rpafi/jl enterprise88. Packt's bestselling Silverlight. Data and Media in Microsoft Silverlight 4: A.

Essentials of Developing Windows Store Apps Using C#

Chapter 1 Getting Started with Windows Presentation Foundation

Full Stack Web Developer

Full Stack Web Developer

DOT NET Syllabus (6 Months)

PASS4TEST. IT Certification Guaranteed, The Easy Way! We offer free update service for one year

Coding Faster: Getting More Productive with Microsoft Visual

Developing Microsoft SharePoint Server 2013 Core Solutions

.NET FRAMEWORK. Visual C#.Net

Transcription:

Pro Business Applications with Silverlight 4 Chris Anderson Apress*

Contents at a Glance Contents About the Author Acknowledgments iv v xix xx a Chapter 1: Introduction 1 Who This Book Is For 1 About This Book 2 About the Author 3 Silverlight Overview 4 What Is Silverlight? 4 A Short History of Silverlight 6 What Can Silverlight Bring to Your Business Application? 7 When Should You Not Use Silverlight? 8 Comparing Silverlight to Other Microsoft Platforms 9 Comparison with Adobe Flash/Flex 11 Business Applications Overview 11 Summary 12 Chapter 2: Getting Started with Silverlight 13 Required Tools 13 Visual Studio 13 Expression Blend 4 and SketchFlow 14

m CONTENTS Silverlight 4 Tools 15 WCF RIA Services 15 Silverlight Toolkit 15 SQL Server 2008 Express Edition 15 Silverlight Spy (and.net Reflector) 16 Creating a Silverlight Application 16 Silverlight Application 17 Silverlight Navigation Application 18 Silverlight Business Application 18 Silverlight Class Library 18 WCF RIA Services Class Library '. 19 Silverlight Unit Test Application 19 Running and Exploring the Default Silverlight Business Application Project 19 Exploring the initial Silverlight Project Structure 22 Project Links 24 The Web Application Project Structure 26 The Silverlight Application Project Structure... 28 Recommended Project Template Modifications 31 XAP Files 32 Summary 33 Chapter 3: An Introduction to XAML 35 Overcoming XAML's Steep Learning Curve 35 Why Learn XAML? 36 XAML Syntax, Document Structure, and Features 37 Core XAML Syntax 37 Creating an Object Hierarchy 38 Namespaces 39 Assigning Property Values to Controls 41

a CONTENTS Attached Properties 44 XAML Namespace Properties 45 Design-Time Properties 46 Markup Extensions 47 Namescopes 49 Controls 50 Base Control Classes, 51 Layout Controls 53 XAML vs. Windows Forms Controls' Property Names 57 Assigning Event Handlers 58 Creating a Simple User Interface 60 Resources and Resource Dictionaries 62 Styles 64 Templates 65 Data Binding 65 Binding to an Object 66 Binding to a Collection 69 Designing User Experiences... 70 The Designer/Developer Workflow 71 XAML User Interfaces: A Different Perspective 71 Summary 72 Chapter 4: The Navigation Framework 73 Getting Started with the Navigation Framework 73 Components of the Navigation Framework 75 The Frame Control 75 The Page Class 76 The NavigationService Object 76 The NavigationContext Object 77

CONTENTS Navigating Between Views 77 View URIs 77 Navigation Methods on the Frame Control 78 Navigation Methods on the NavigationService Object 78 Using a HyperlinkButton Control 79 Using the Source Property of the Frame Control 79 User-Initiated Navigation 79 Passing Data Between Views 80 Passing Data Using Query String Parameters 80 Reading Query String Parameters, 81 Passing Complex Data Types Between Views 82 Deep Links 82 URI Mapping to Enable Friendly URIs 83 Integrating with the Browser History 85 Handling Navigation Events 87 Frame Events 87 View Events 88 Caching Views 89 Visual Transition Effects 90 Alternative User Interface Frameworks 91 Summary 91 Chapter 5: Exposing Data from the Server: Using WGF RIA Services 93 WhatlsWCF RIA Services? 94 How the WCF RIA Services Code Generator Works 95 How Do You Use WCF RIA Services? 96 Linking Your Silverlight and Web Projects 97 Creating Your Domain Services 97 Creating Domain Operations on Your Domain Services 97 viii

CONTENTS Consuming the Domain Services 98 Getting Started 98 Creating a Data Access Layer Using the Entity Framework 101 Configuring the Database 101 About the Entity Framework 101 Creating an Entity Model 102 Domain Services 102 Understanding the Domain Service Life Cycle 103 Creating a Domain Service 104 Domain Operations 107 Query Operations 107 Insert/Update/Delete Operations 109 Invoke Operations 111 Custom Operations 111 Decorating Entities 112 Metadata Classes 113 Controlling Client Entity Generation 113 Validation 115 Presentation 118 Miscellaneous Data Annotations 118 Presentation Model Types 119 Creating the Presentation Model Class 120 Populating and Exposing Your Presentation Model Types 121 Updating Your Presentation Model Types 122 Sharing Code/Logic Across Tiers 123 Inspecting the Generated Code in the Silverlight Project 124 Encapsulating Logic in a Separate WCF RIA Services Class Library 125 Handling Server Errors 126

«CONTENTS Handling Data Concurrency Violations 127 Methods of Identifying Concurrency Violations 127 Configuring the Entity Model to Checkfor Concurrency Violations 128 Testing Your Solution 129 Resolving Conflicts in the Domain Service 130 Transactions 131 WCF RIA Services Toolkit 132 Alternative Communication Technologies 133 WCF Services 134 WCF Data Services, 137 HTTP Requests 138 Sockets 139 Summary 139 Chapter 6: Implementing Summary Lists 141 Exposing a Summary Collection from the Server 142 Collections and Collection Views 144 ObservableCollection<T> 144 Views 144 Consuming Data from the Server 146 Understanding the Domain Context 146 XAML-Based Approach 146 Code-Based Approach 148 Choosing the Right Approach 149 Explicitly Specifying a Domain Service Host 150 Using the Busylndicator Control 150 Displaying the Summary List 152 Retrieving the Data from the Server 153 Configuring and Customizing a Control for Displaying Data 153 x

B CONTENTS Choosing the Right Control 164 Manipulating Summary Lists 165 Querying Data Exposed by a Domain Operation 165 Filtering the Summary List 168 Sorting the Summary List 170 Grouping the Summary List 172 Paging the Summary List 175 Drilling Down on a Record 178 Opening Details in a New View 179 Opening Details in a Pop-Up Window 180 Displaying Details Using the DataGrid's Row Details 183 Implementing a Master/Details View 184 Handling Errors 184 Summary 187 Chapter 7: Building Data Entry Forms 189 Creating the Data Entry User Interface 189 Laying Out the Data Entry Form 189 Refining the Data Entry Form's Functionality 201 Using the DataGrid for Data Entry 212 Structuring Objects for Use by Data Entry Forms 216 Implementing the INotifyPropertyChanged Interface 216 Implementing the leditableobject Interface 220 Adding Calculated Properties to Your Classes 222 Data Validation 223 Displaying Validation Errors 223 Types of Data Validation 226 Defining Validation Rules 227 Exposing Validation Errors to the User Interface 228

CONTENTS Notifying the User Interface of Object-Level Validation Errors 234 The Validator Class 235 Customizing Validation Attribute Error Messages 238 Submitting Changes to the Server 238 Change-Tracking 238 Submitting Changes via the DomainDataSource Control 239 Submitting Changes via a Domain Context 239 Handling Errors 240 Handling Concurrency Violations 242 Summary 243 Chapter 8: Securing Your Application 245 Implementing Server-Side Security Using RIA Services 245 The ASP.NET Membership API 246 Configuring Your Database for Forms Authentication 247 Authentication 249 Requiring Authentication 250 Role-Based Operation Access Restrictions 251 Returning a Subset of Data Based on the User's ID or Role 253 Permitting Update/Delete Operations According to Data 253 Exposing Custom User Profile Data 253 User Registration 254 Avoiding SQL Injection Attacks 255 Sanitizing Errors Sent to the Client 256 Implementing Client-Side Security 256 Authenticating and Registering Users 256 Accessing and Updating User Information 259 Implementing Client-Side Restrictions 260 Storing Data Locally 262 Encrypting Data Passed Between the Server and the Client 262 xii

CONTENTS Cross-Domain Access Policies 263 Implementing Cross-Domain Policies for HTTP-Based Communication 264 Implementing Cross-Domain Policies for Socket-Based Communication 265 Implementing Cross-Scheme Access Policies 265 Restricting Access to Your Application 266 Summary 268 Chapter 9: Styling Your Application 269 The Designer/Developer Workflow 269 Defining Style Resources 271 Defining a Style Resource 272 Defining Style Resources at Various Locations 273 Naming Style Resources 275 Inheriting Style Resources 276 Styling Constraints 277 Control Templates 277 Default Control Templates 278 Templating a Control 278 Control Template Structure 279 Them'mg 282 Creating a Custom Theme 282 Silverlight Toolkit Themes 283 4. Silverlight Navigation/Business Application Themed Project Templates 283 Icons and Images, 283 Animation 284 Pixel Shaders / Effects 284 Miscellaneous Styling Tips 285 Defining Constants in XAML 285 Restoring a Control's Default Style 286 xiii

a CONTENTS Summary. 286 Chapter 10: Advanced XAML and Data Binding 287 Advanced XAML 287 Comments in XAML 287 Defining Constants 288 Using OR to Combine Enumerated Values in XAML 289 Triggers, Actions, and Behaviors 289 Blendability 299 Creating Consolidated Namespaces 301 MoXAML Power Toys 303 Advanced Data Binding 303 Assigning the Source of a Binding 304 Binding to a Resource 308 Defining Resources in the Code-Behind (For Binding To) 311 Binding to Nested Properties 311 Binding to Indexed Properties 312 Binding to Collection Views 312 Enhancing Data Binding 317 Data Binding in Code 323 Getting and Setting Attached Property Values in Code 324 Additional Tips 324 Summary 329 Chapter 11: Creating Custom Controls 331 Adding Functionality to an Existing Control 331 Creating User Controls 332 Creating a Simple User Control 332 Exposing Properties 333 Exposing Methods 345 xiv

is CONTENTS Exposing Events 346 Determining If in Design-Time or Runtime Mode 347 Constraining the User Control's Size 347 Creating Custom Controls 347 Creating the Custom Control 348 The Control Structure 349 Defining the Control's Default Template 350 Defining the Control's Behavior 359 Content Controls 365 Containing a Single Control as Content 365 Containing Multiple Controls as Content 367 Attached Properties 369 Summary 370 Chapter 12: The Model-View-ViewModel (MWM) Design Pattern, 373 The Purpose of Implementing MWM 374 Why You Should Implement MWM 375 MWM Theory 376 The Layers 376 View / View Model Configurations 379 MWM in Practice 380 Creating the Layers 380 Connecting the Layers 383 View and ViewModel Interactions 385 Layer Interaction Summary 392 Hotly Debated Implementation Details 393 MWM and RIA Services 395 Implementing the Model 395 Implementing the View Model 396 XV

a CONTENTS Implementing the View 399 Frameworks 401 Summary 401 Chapter 13: Printing and Reporting... 403 The Importance of Implementing Reporting 403 Potential Solutions for Implementing Reporting 404 Generating a PDF 404 Generating HTML 405 Generating Office Documents 405 Using Silverligrrt 4 Printing Functionality 405 Third-Party Report Viewers 405 Office Integration Using COM 407 Choosing a Reporting Strategy 407 Printing Functionality in Silverlight..407 Generating and Displaying a PDF Report 409 Generating a Report on the Server 409 Displaying the Report on the Client 418 Summary 426 a Chapter 14: Out of Browser Mode, and Interacting with the Operating System 427 Out of Browser 427 Configuring 00B Mode 428 Installing the Application to Run Out of Browser 429 Determining Installation Status 431 Determining Whether Running Inside or Outside the Browser 432 Where/How is the Application's.xap File Stored and Run? 432 Interacting with the OOB Window 433 Checking for Updates 434 xvi

CONTENTS Debugging Out of Browser, 436 Uninstalling the Application 436 Toast Notifications 437 Caching Data Locally 439 Caching to Isolated Storage 439 Caching to a Client-Side Database 449 Detecting Network Connection Availability 451 File System Open/Save Dialogs 451 The Open File Dialog, 452 The Save File Dialog 456 Drag Drop Target 459 Clipboard 460 Full Screen 462 Initiating Full Screen Mode 462 Detecting the Switch to and from Full Screen Mode 463 Retaining Full Screen Mode When Unfocused 463 Keyboard Access 464 Elevated Trust 464 Enabling Elevated Trust 465 File System Access 466 COM Automation 471 Custom Chrome 478 Other Restrictions Lifted By Elevated Trust 480 Restrictions Imposed by Elevated Trust 481 Disabling Elevated Trust Applications with a Windows Group Policy 481 Summary 482 i Chapter 15: Application Deployment 483 Deploying the Application, to the Server 483

CONTENTS Server Requirements 484 Using Xcopy 485 Publishing 486 Creating a Web Package 487 Creating a Setup Program 488 Deploying the Application to the Client 488 The Default Silverlight Installation Process 489 Customizing the Silverlight Installation Experience 490 Pushing the Silverlight Runtime to Users in the Enterprise 493 Building a Client Desktop Installer 494 Improving on the Default Application Loading Screen 495 Creating the Application Pre-loader Files 496 Designing the Application Pre-loader 497 Updating the Application Download Progress 499 Configuring the Application Pre-loader in the HTML File 500 Testing the Application Pre-loader 500 Partitioning Your Application 502 Initial Steps 502 Assembly Caching 502 Downloading Modules on Demand 505 Digitally Signing Your Application 506 Summary 511 H Index, 513 xviii