part 2 (mike) control templating custom controls custom layout openfiledialog html integration deep...

53
Building Rich Internet Applications Using Microsoft Silverlight Mike Harsh Microsoft Corporation Joe Stegman Microsoft Corporation

Upload: naomi-cain

Post on 23-Dec-2015

222 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Building Rich Internet Applications Using Microsoft Silverlight

Mike HarshMicrosoft Corporation

Joe StegmanMicrosoft Corporation

Page 2: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Agenda

Part 2 (Mike)Control TemplatingCustom ControlsCustom LayoutOpenFileDialogHTML IntegrationDeep ZoomLocal StorageQ&A

Part 1 (Joe)OverviewGetting StartedBuild an Application

NetworkingXMLControlsData Binding

Page 3: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Silverlight 2 Runtime Features

2D, GraphicsAudio, VideoAnimationsText, Text Input*Controls*Layout*Styles/Templates*Data Binding*Networking

HTTP/S and Sockets*

* New in Silverlight 2

.NET Support*C# and VB.NET*

LINQ*XML APIs*Generics*HTML Integration*

JSON SerializerLocal storage*Crypto APIs (AES)*Threading*

Page 4: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Silverlight 2 SDK Libraries

Dynamic Languages*JScriptIronRubyIronPython

Additional Controls*LINQ for XML*XML Serialization*Syndication APIs (RSS)*

* New in Silverlight 2

Page 5: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Silverlight Roadmap

Silverlight V1 Shipped Q307Silverlight V2

March 5th Beta 1 (non-commercial go-live)Q208: Beta 2 (go live)

ToolsExpression Suite and Visual Studio updates for all public Silverlight releasesVisual Studio Designer support (Cider) later this year

Page 6: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Getting Started

an old-ish dog with new-ish tricksand a new dog doing old tricks

demo

Page 7: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Build an Application

Step 1: Get DataStep 2: Convert XML data to .NET objectsStep 3: Build Main (Master) ViewStep 4: Create a Details ViewStep 5: Add Search and UX Animations

Page 8: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Build an Application

Step 1: Get DataNetwork data from site of originNetwork data from cross domain (x-domain)*Local data

Page 9: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Silverlight Sandbox

Silverlight lives in the browser SandboxDevelopers cannot extend the sandboxSilverlight extends in a secure way

Local storage (isolated storage)Similar to cookies

FileOpen dialogSockets

Beta 1: Site of origin, port restrictions

Cross domain HTTP(S) requestsSupport Silverlight and Subset of Flash policy files

Page 10: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Build an Application

Step 1: Get DataGet data from http://catalog.video.msn.com/Secured via a Silverlight policy file

Page 11: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Networking

demo

Page 12: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Build an Application

Step 1: Get DataStep 2: Convert XML data to .NET objects

Options:LINQ to XML XMLReaderXML Serialization

Page 13: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Convert XML to Objects(XML -> List<VideoSource>)

demo

Page 14: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Build an Application

Step 1: Get DataStep 2: Convert XML data to .NET objectsStep 3: Build Main (Master) View

Page 15: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Beta 1 ControlsCanvasFileOpenDialogGridImageItemsControlMediaElementMultiScaleImageStackPanelTextBoxTextBlockButtonPopup

CheckBox*DataGrid*DateTimePicker*GridSplitter*Hyperlink*ListBox*Calendar*RadioButton*Slider*ToggleButton*Tooltip*WatermarkTextBox*

* ship in a separate libraryNote: additional controls to follow between Beta 1 and final

release

Page 16: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Layout

Layout containersCanvas, Grid, StackPanel, Border

Layout propertiesWidth, MinWidth, MaxWidth, ActualWidthHeight, MinHeight, MaxHeight, ActualHeightMargin and Padding

Layout extensibility

Page 17: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Data Binding

Property BindingOne way, two way and one timeUse “DataContext” propertySupports value converters

Collection/List BindingSupport data templates (repeater)Use “ItemsSource” property

Page 18: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

List Binding with Data Templates

{{FileName=“Html.html”, FileImageUrl=“html.jpg”},

{FileName=“Image.jpg”, FileImageUrl=“jpg.jpg”}}

Data Template:

Data (.NET Object):

Bind using ItemsControl (List Control):

Page 19: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Build an Application

Step 1: Get DataStep 2: Convert XML data to .NET objectsStep 3: Build Main (Master) View

Use Data Binding, Layout and Templates

Page 20: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Build the Master View

demo

Page 21: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Build an Application

Step 1: Get DataStep 2: Convert XML data to .NET objectsStep 3: Build Main (Master) ViewStep 4: Creating a Detail View

Make a re-usable controlStep 5: Add Search and UX Animations

Time permitting

Page 22: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Finishing the Application

demo

Page 23: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Related Sessions

Integrating Media in Silverlight ApplicationsThursday, March 6 8:30 AM - 9:45 AM, San Polo 3501A

Encoding Video for Microsoft Silverlight Delivery Scenarios

Wednesday, March 5 3:00 PM - 4:15 PM, Delfino 4105

Creating Rich, Dynamic User Interfaces with Silverlight 2 Controls

Thursday, March 6 10:15 AM - 11:30 AM, Lando 4204

Silverlight and the Advertising OpportunityWednesday, March 5 4:30 PM - 5:45 PM, San Polo 3501A

Working with Data and Web Services in Microsoft Silverlight 2

Wednesday, March 5 1:30 PM - 2:45 PM, Delfino 4105

Lighting Up Your AJAX Applications with SilverlightFriday, March 7 10:00 AM - 11:15 AM, Lando 4204

Page 24: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Building RIAs Using Silverlight 2Mike HarshProgram ManagerMicrosoft Corporation

Page 25: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Part 2 – Making Apps Sticky

AgendaReview part 1Control TemplatingCustom Controls & LayoutsLocal StorageHTML IntegrationOpenFileDialogDeep ZoomQ&A

Page 26: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

What Joe Showed You…

Silverlight 2.0 has a rich UI framework built-inCan provide AJAX++ experiences with very little codeHowever…

You can take your app to 11 with Silverlight 2.0

Page 27: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Silverlight 1

Page 28: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Silverlight 2

Page 29: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Styling / Skinning

Customize the look of an application without changing it’s behavior3 levels of customization:

Page 30: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Styling / Skinning

Customize the look of an application without changing it’s behavior3 levels of customization:

Page 31: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Styling / Skinning

Customize the look of an application without changing it’s behavior3 levels of customization:

Page 32: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Styling / Skinning

Customize the look of an application without changing it’s behavior3 levels of customization:

Page 33: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Styling / Skinning

Silverlight UI customization is designed to easily enable the styling and skinning modelsEasy for designers and developers to understandDesigned for toolabilitySkins can be easily ported to WPF

Page 34: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Styling / Skinning

Parts Based Model:Control authors define parts of a controlAdd metadata so tools can discover parts and customize them in a templateTemplates are defined in XAML and are reusable

DownButton

UpButtomThumb

Track

Page 35: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Custom Control Template

demo

<ControlTemplate <Storyboard x:Name="STATE_MousePressed"> <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rectangle" Storyboard.TargetProperty=“fill"> <SplineColorKeyFrame KeyTime="00:00:00" Value="#FF2F2727"/></ColorAnimationUsingKeyFrames> </Storyboard> <Rectangle Fill="Black" x:Name="ELEMENT_Rectangle"/></ControlTemplate>

+ =

Page 36: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Custom Controls & Layouts

.NET programming model brings componentization and reuse to Silverlight

Custom XAML elements can be created using .NET inheritanceLayout engine can also be extendedWPF attached property model allows existing components to learn new tricksClasses can be used to encapsulate common functionality

Page 37: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Custom Layout Container

demo

Page 38: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Local Storage

Cookies on steroidsProvides 10MB of app specific local storageCan be expanded per app by prompting the userUses .NET IsolatedStorage APIs

Page 39: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Storing Previous Search

demo

Page 40: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

HTML DOM Integration

Silverlight apps are browser appsInteracting with the browser host is critical

Interact with HTML elements and script objects through .NET codeExpose .NET objects to javascript

Page 41: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

HTML DOM Integration

Typical HTML DOM pattern

Page 42: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Browser History Integration

demo

Page 43: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Open File Dialog

Allows an end-user to choose a fileApplication gets access to a streamSupports multi-selection and file extension filteringEnables:

File uploading (w/ HttpWebRequest)Viewing local images (w/ Image element)Playing local media (w/ MediaElement)

Page 44: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Local Video Playback

demo

Page 45: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Image Deep Zoom

Provides seamless viewing & zooming of huge imagesLoads only the data necessary to show the part of an image the user is viewingEffectively turns a large image into an efficiently scaling vector

Page 46: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Image Deep Zoom

Preprocessing tool breaks image into 256 x 256 tilesThen generates pyramids of tiles at lower resolutions

Page 47: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Deep Zoom – How does it work?

When the image is displayed on the client the lowest resolution tiles are shown firstThen as the higher quality tiles are downloaded, they are smoothly blended in

Page 48: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Deep Zoom – How does it work?

When the image is displayed on the client the lowest resolution tiles are shown firstThen as the higher quality tiles are downloaded, they are smoothly blended in

Page 49: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Deep Zoom – How does it work?

When the image is displayed on the client the lowest resolution tiles are shown firstThen as the higher quality tiles are downloaded, they are smoothly blended in

Page 50: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Image Deep Zoom

Exposed through the MultiScaleImagePreprocessing tool outputs image tiles and XML description file

Page 51: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

Using Deep Zoom

demo

Page 52: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting

© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.

The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after

the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Page 53: Part 2 (Mike) Control Templating Custom Controls Custom Layout OpenFileDialog HTML Integration Deep Zoom Local Storage Q&A Part 1 (Joe) Overview Getting