SlideShare una empresa de Scribd logo
1 de 55
Welcome! AppDev’s Silverlight 4 for Visual Studio 2010 Using Visual Basic Instructor: Bill Hatfield Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Introducing Silverlight 4! Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Objectives Introduce Silverlight Investigate XAML and the XAML designer in Visual Studio 2010 Learn about XAML controls, properties, and events Work with container controls, dependency properties, and the Grid control Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Agenda Introducing Silverlight Introducing XAML and the Silverlight Designer Investigating XAML Introducing Content and Grid Controls Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Introducing Silverlight Cross-browser, cross-platform plug-in Create rich interactive applications (RIAs) for the Web Originally seen as a competitor to Flash  Lightweight runtime (under 5 MB) Based on XAML Quick demonstration: http://www.microsoft.com/silverlight Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Copyright 2010, AppDev Products, LLC.    All Rights Reserved. Why Silverlight? Delivers the best of both worlds: Leverages .NET Framework Creates rich Internet experiences Provides class library support for rapid development
Why Silverlight? Beyond HTML Keeps users engaged  Combines animation, video, vector graphics, perspective 3D, effects, features like Deep Zoom Fastest Web Experiences Put any CPU to work Multi-threading support Tap into 100+ Controls Silverlight allows you to skin controls using mark-up Easier to have controls fit your task or brand Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Why Silverlight? Highest quality media Up to 1080p true HD-quality video Uses H.264 (MP4) or WMV with Smooth Streaming Mac, Windows, and Linux Works with every major operating system All major browsers Go out of Browser Can install applications on desktop Run apps seamlessly without connectivity Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Evolution of Silverlight Silverlight 1 Support for scripting languages only Interesting layout capabilities Great for streaming videos Silverlight 2 Support for .NET Framework and CLR Data binding Isolated storage Support for calling services Cross-domain network access Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Silverlight 3 Navigation Framework Build apps with multiple pages Navigation via links More controls and layout capabilities Modal windows Element-to-element binding Data validation Ability to run outside the browser Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Silverlight 4 Printing support Several new controls, including DataGrid Enhanced data binding, including drag and drop “Toast” notification windows Offline DRM For trusted applications COM Interop Reading/writing user’s special folders New interface for requesting application privileges Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Silverlight Development Tools Visual Studio 2008 (Silverlight 3) Download the Silverlight 3 Toolkit No visual designer Visual Studio 2010 (Silverlight 3 or 4) Build Silverlight applications out of the box Full tooling Download Silverlight 4 Expression Blend 3 (and now 4!) Powerful tool for building layout, animation, effects Bit of a learning curve (made for designers) Not free, but included in MSDN subscriptions Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Getting Started Verify that Silverlight has been installed Navigate to: http://www.microsoft.com/silverlight/get-started/install/default.aspx Can also use Control Panel to verify version Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Getting Started Build Silverlight solutions in Visual Studio Suggestion:  Consider using Expression Blend for more complex styling, templating, animations, and so on Three types of Silverlight projects Silverlight Application template creates simple application Silverlight Navigation Application template provides a jumpstart for more sophisticated multi-page  apps Silverlight Library creates DLL  Makes it easier to partition logic and features Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
WPF vs. Silverlight Microsoft provides two technologies for client-side applications: WPF and Silverlight Both allow you to create client applications Both use XAML to design the interface WPF has entire .NET Framework behind it Silverlight works with a small subset of Framework Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
WPF vs. Silverlight WPF: Ships as part of .NET Framework (3.0 and later) Runs only on Windows (XP or better) Runs as a stand-alone Windows app or as a Web Browser app (XBAP) XBAPs require the .NET Framework on the client (where the browser is running) Browser compatibility: IE only in .NET 3.0; IE and Firefox in .NET 3.5 and later Provides richest functionality Full support for 3D graphics Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
WPF vs. Silverlight Silverlight: Ships independently; isn’t part of .NET Framework Is typically hosted in a Web browser Broad browser support including IE, Firefox, Safari Cross-platform - Runs on Windows, Mac, Linux clients Provides a subset of WPF’s features And only small subset of .NET Framework Which do you use? Depends on target audience, technological needs, preferred deployment Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
An Inconvenient Truth (or Two) Far more difficult to create a decent-looking application in XAML Because the bar is so much lower in other environments Developers creating applications in XAML generally create ugly applications Good XAML applications require graphic designers On the other hand… Far easier to create great-looking application  Because Windows and Web forms are so limited  Also check out Microsoft Expression Studio Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Silverlight and XAML Silverlight and XAML: The same thing? XAML is XML-based grammar that can be used to declaratively define Silverlight applications Can also use Silverlight libraries and code the interface XAML <-> Silverlight libraries are not a one-to-one mapping Some names in used in creating a Silverlight interface in XAML don’t match exactly with the corresponding library class/collection/property names Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Agenda Introducing Silverlight Introducing XAML and the Silverlight Designer Investigating XAML Introducing Content and Grid Controls Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Introducing XAML Build Silverlight solutions in Visual Studio Use Expression Blend for sophisticated styling, templating, animations, and more Silverlight projects Silverlight Application template creates simple application Outputs XAP file, downloaded by the Silverlight runtime Silverlight Navigation Application template provides a jumpstart for multi-page apps Silverlight Library creates DLL  Makes it easier to partition logic and features Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Additional Silverlight 4 Projects Silverlight 4 adds more project types: Silverlight Business Application Includes login and membership  WCF RIA Services Class Library Focus on Silverlight Application template in this course Visual Studio 2010 doesn’t include all Silverlight controls Download Silverlight Toolkit to get the rest http://www.codeplex.com/Silverlight Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Your First Silverlight Application Pages 1-8 to 1-10 Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Agenda Introducing Silverlight Introducing XAML and the Silverlight Designer Investigating XAML Introducing Content and Grid Controls Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Investigating XAML XAML is simple But provides several different ways to set property values Simple Properties/Type Converters Complex Properties Markup Extensions Attached Properties Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Simple Properties/Type Converters Dragging Button control onto design surface creates several properties Markup counts on Button class providing Content, Height, HorizontalAlignment, Margin, Name, VerticalAlignment, and Width properties Some properties are simple strings Content and Name properties Others are more complex Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Type Converters Height and Width properties? Properties are numeric Markup supplies values as strings Along the line, some code must convert Works because Integer class provides built-in conversion from string Other properties even more complex: HorizontalAlignment and VerticalAlignment? Need to convert from string (Bottom, Center, Stretch, or Top; Center, Left, Right, Stretch) to enumerated values Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Type Converters Margin adds own set of issues Can supply a single value (all four sides) Can supply two values (left/right and top/bottom) Can supply four values (left, top, right, bottom) Margin property is a Thickness structure Contains four integers Setting property calls constructor for Thickness structure Requires converter to read the comma-delimited string and convert to a call to the constructor Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Complex Properties Type converters work well Some properties can’t be represented by single value Want to specify background of a Grid control as a linear gradient? Can’t represent the behavior with a single value Properties of elements that are themselves objects with properties require special care Represent as nested elements  Named Parent.Property (Grid.Background) Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
DEMO Page 1-22: Complex Properties, Try It Out! Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Markup Extensions Usually, standard XAML markup provides functionality you need Sometimes not possible to set property value at design time Some properties must be set dynamically, at runtime Need to use markup extension Allows you to set property in non-standard way Can specify markup extension as nested element, or as attribute As attribute, always surrounded with {  } Indicating value supplied at runtime Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Markup Extensions Declarative binding requires markup extension: Can also express using child element: Copyright 2010, AppDev Products, LLC.    All Rights Reserved. Property=  "{Binding ElementName=ObjectName,             Path="PropertyName}" <Object.Property>   <Binding ElementName="ObjectName",            Path=PropertyName"/> </Object.Property>
DEMO Markup extension/binding Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Attached Properties Nest a control within a Grid Specify its row and column with Grid.Row and Grid.Column properties Where did these come from?  Child control doesn't supply! Grid adds these to all its child controls In other words, they're attached properties Properties appear as properties of the class But they're defined in a different class (Grid, in this case) Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Attached Properties Specific syntax: DefiningType.PropertyName Grid.Row Aren't actually properties Converted to method calls by compiler Defining class must provide GetPropertyName and SetPropertyName methods Grid.GetRow and Grid.SetRow Technique hides what's really going on Calling method in defining class? Does Grid keep track of all its children's coordinates? Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Attached Properties Of course, Grid doesn't keep track of all its children's coordinates Child controls all inherit from DependencyObject Defined to maintain an unlimited number of dependency properties Parent (Grid) maintains a single instance of a field for each property Grid.RowProperty for Grid.Row, for example Child maintains its own value for that property Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Attached Properties Calling parent control's GetPropertyName and SetPropertyNamemethods equivalent to calling GetValue and SetValue methods of child object To retrieve Grid.Row property of TextBox named DemoTextBox, use expression like: Copyright 2010, AppDev Products, LLC.    All Rights Reserved. DemoTextBox.GetValue(Grid.RowProperty)
Agenda Introducing Silverlight Introducing XAML and the Silverlight Designer Investigating XAML Introducing Content and Grid Controls Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Content and Grid Controls Many controls inherit from ContentControl (including Button) and can contain other controls Button with image and text?  No problem! ListBox containing a bunch of TextBox controls?  No problem! Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Working with Layout Controls Several controls useful for laying out other controls DockPanel Allocates an edge for each child control Useful for defining rough layout StackPanel Stacks children horizontally or vertically Useful internal to other controls (Button, for example) Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Working with Layout Controls Grid Arranges children in a grid No need for fixed sizes or positions Rescales when resized Canvas No layout logic Manually control each aspect of layout Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
List Box as Container DEMO Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Working with the Grid Control DEMO Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Dependency Properties In standard .NET code, property is defined using two procedures “setter” and “getter” More complex mechanism here Workflow uses same mechanism Dependency properties allow for: Styling Automatic data binding Animation Change notification and more… Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
DependencyObject Class DependencyProperty class acts as base for the properties DependencyObject is base for classes that can consume and expose dependency properties XAML classes expose far more properties than the corresponding prior classes Need some internal plumbing to handle Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Investigating DependencyProperty .NET maintains internal dictionary of classes and the properties they expose DependencyProperty instance defined as a static/shared member of a class In constructor, code registers property, its type, and hosting class with .NET Can optionally create standard .NET property that wraps up the dependency property Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Declaring the Property Copyright 2010, AppDev Products, LLC.    All Rights Reserved. VB: Public Shared IsAvailableProperty As DependencyProperty C#: public static DependencyProperty IsAvailableProperty;
In Constructor Copyright 2010, AppDev Products, LLC.    All Rights Reserved. [Visual Basic] MyClass.IsAvailableProperty = _    DependencyProperty.Register("IsAvailable", _    GetType(Boolean), GetType(MyClass)) [C#] MyClass.IsAvailableProperty =   DependencyProperty.Register("IsAvailable",   typeof(bool), typeof(MyClass))
Property Wrapper Copyright 2010, AppDev Products, LLC.    All Rights Reserved. [Visual Basic] Public Property IsAvailable() As Boolean  Get    Return _    CType(GetValue(MyClass.IsAvailableProperty), Boolean)  End Get  Set(ByVal value As Boolean)    SetValue(MyClass.IsAvailableProperty, value)  End SetEnd Property
Property Wrapper Copyright 2010, AppDev Products, LLC.    All Rights Reserved. [C#] public bool IsAvailable{  get {     return (bool) GetValue(MyClass.IsAvailableProperty); }  set { SetValue(MyClass.IsAvailableProperty, value) }}
Using Attached Properties Button control doesn’t expose Grid.Column or Grid.Row Yet these attributes exist in the XAML markup These are attached properties Properties added by container, when hosted Retrieve and set using DependencyObject.GetValue and DependencyObject.SetValue Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Working with Attached Properties Copyright 2010, AppDev Products, LLC.    All Rights Reserved. [Visual Basic] Dim row As Integer =   CType(DemoButton.GetValue(Grid.RowProperty), Integer) DemoButton.SetValue(Grid.RowProperty, row + 1)  [C#] int row = (int)DemoButton.GetValue(Grid.RowProperty); DemoButton.SetValue(Grid.RowProperty, row + 1);
Interacting with the Grid Add code to move button to new row Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Running Out of Browser Silverlight applications distributed through browser But applications can be run locally: no connection! Even when run locally Silverlight apps use only small subset of .NET Framework Apps are still sandboxed Can’t do anything destructive unless granted permission explicitly No connectivity required Simple to install and uninstall Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Running Out of Browser DEMO Copyright 2010, AppDev Products, LLC.    All Rights Reserved.

Más contenido relacionado

La actualidad más candente

IBM WebSphere Portal References Education
IBM WebSphere Portal References EducationIBM WebSphere Portal References Education
IBM WebSphere Portal References EducationDvir Reznik
 
Adobe AIR Programming to Desktop and Mobile
Adobe AIR Programming to Desktop and MobileAdobe AIR Programming to Desktop and Mobile
Adobe AIR Programming to Desktop and MobilePasi Manninen
 
Adobe's RIA Technologies (non technical)
Adobe's RIA Technologies (non technical)Adobe's RIA Technologies (non technical)
Adobe's RIA Technologies (non technical)Cyril Hanquez
 
Max 2010: Having Fun Flex4 Layouts
Max 2010: Having Fun Flex4 LayoutsMax 2010: Having Fun Flex4 Layouts
Max 2010: Having Fun Flex4 LayoutsXavi Beumala
 
Enrique Duvos: Adobe RIA Platform
Enrique Duvos: Adobe RIA PlatformEnrique Duvos: Adobe RIA Platform
Enrique Duvos: Adobe RIA PlatformInitium
 
Real World SharePoint Framework and Azure Services
Real World SharePoint Framework and Azure ServicesReal World SharePoint Framework and Azure Services
Real World SharePoint Framework and Azure ServicesBrian Culver
 
Uncovering the Latest in SharePoint Development
Uncovering the Latest in SharePoint DevelopmentUncovering the Latest in SharePoint Development
Uncovering the Latest in SharePoint DevelopmentEric Overfield
 
MSDN Unleashed: WPF Demystified
MSDN Unleashed: WPF DemystifiedMSDN Unleashed: WPF Demystified
MSDN Unleashed: WPF DemystifiedDave Bost
 
SPCA2013 - Building Windows Client Applications for SharePoint 2013
SPCA2013 - Building Windows Client Applications for SharePoint 2013SPCA2013 - Building Windows Client Applications for SharePoint 2013
SPCA2013 - Building Windows Client Applications for SharePoint 2013NCCOMMS
 
Move past bootstrap and build our lightweight responsive framework w.v1.2
Move past bootstrap and build our lightweight responsive framework w.v1.2Move past bootstrap and build our lightweight responsive framework w.v1.2
Move past bootstrap and build our lightweight responsive framework w.v1.2Eric Overfield
 
Flex And Ria
Flex And RiaFlex And Ria
Flex And Riaravinxg
 
Moving to Microsoft Visual Basic .NET
Moving to Microsoft Visual Basic .NETMoving to Microsoft Visual Basic .NET
Moving to Microsoft Visual Basic .NETV Sanchez
 
San Francisco PHP Meetup Presentation on Zend Framework
San Francisco PHP Meetup Presentation on Zend FrameworkSan Francisco PHP Meetup Presentation on Zend Framework
San Francisco PHP Meetup Presentation on Zend Frameworkzend
 
Developing service component architecture applications using rational applica...
Developing service component architecture applications using rational applica...Developing service component architecture applications using rational applica...
Developing service component architecture applications using rational applica...Bill Duncan
 
WebSphere Portal Business Overview
WebSphere Portal Business OverviewWebSphere Portal Business Overview
WebSphere Portal Business OverviewJoel Demay
 

La actualidad más candente (19)

IBM WebSphere Portal References Education
IBM WebSphere Portal References EducationIBM WebSphere Portal References Education
IBM WebSphere Portal References Education
 
Flex3
Flex3Flex3
Flex3
 
Adobe AIR Programming to Desktop and Mobile
Adobe AIR Programming to Desktop and MobileAdobe AIR Programming to Desktop and Mobile
Adobe AIR Programming to Desktop and Mobile
 
Adobe's RIA Technologies (non technical)
Adobe's RIA Technologies (non technical)Adobe's RIA Technologies (non technical)
Adobe's RIA Technologies (non technical)
 
Beginners introduction to asp.net
Beginners introduction to asp.netBeginners introduction to asp.net
Beginners introduction to asp.net
 
Max 2010: Having Fun Flex4 Layouts
Max 2010: Having Fun Flex4 LayoutsMax 2010: Having Fun Flex4 Layouts
Max 2010: Having Fun Flex4 Layouts
 
Enrique Duvos: Adobe RIA Platform
Enrique Duvos: Adobe RIA PlatformEnrique Duvos: Adobe RIA Platform
Enrique Duvos: Adobe RIA Platform
 
Real World SharePoint Framework and Azure Services
Real World SharePoint Framework and Azure ServicesReal World SharePoint Framework and Azure Services
Real World SharePoint Framework and Azure Services
 
Uncovering the Latest in SharePoint Development
Uncovering the Latest in SharePoint DevelopmentUncovering the Latest in SharePoint Development
Uncovering the Latest in SharePoint Development
 
MSDN Unleashed: WPF Demystified
MSDN Unleashed: WPF DemystifiedMSDN Unleashed: WPF Demystified
MSDN Unleashed: WPF Demystified
 
SPCA2013 - Building Windows Client Applications for SharePoint 2013
SPCA2013 - Building Windows Client Applications for SharePoint 2013SPCA2013 - Building Windows Client Applications for SharePoint 2013
SPCA2013 - Building Windows Client Applications for SharePoint 2013
 
Move past bootstrap and build our lightweight responsive framework w.v1.2
Move past bootstrap and build our lightweight responsive framework w.v1.2Move past bootstrap and build our lightweight responsive framework w.v1.2
Move past bootstrap and build our lightweight responsive framework w.v1.2
 
IBM WebSphere Portal
IBM WebSphere PortalIBM WebSphere Portal
IBM WebSphere Portal
 
Flex And Ria
Flex And RiaFlex And Ria
Flex And Ria
 
Moving to Microsoft Visual Basic .NET
Moving to Microsoft Visual Basic .NETMoving to Microsoft Visual Basic .NET
Moving to Microsoft Visual Basic .NET
 
Hello Gumbo
Hello GumboHello Gumbo
Hello Gumbo
 
San Francisco PHP Meetup Presentation on Zend Framework
San Francisco PHP Meetup Presentation on Zend FrameworkSan Francisco PHP Meetup Presentation on Zend Framework
San Francisco PHP Meetup Presentation on Zend Framework
 
Developing service component architecture applications using rational applica...
Developing service component architecture applications using rational applica...Developing service component architecture applications using rational applica...
Developing service component architecture applications using rational applica...
 
WebSphere Portal Business Overview
WebSphere Portal Business OverviewWebSphere Portal Business Overview
WebSphere Portal Business Overview
 

Similar a Silverlight Chapter 01 - Introduction

Uncovering Windows - Silverlight Seminar
Uncovering Windows - Silverlight SeminarUncovering Windows - Silverlight Seminar
Uncovering Windows - Silverlight SeminarAbram John Limpin
 
Tech Lunch 9 25 2008
Tech Lunch 9 25 2008Tech Lunch 9 25 2008
Tech Lunch 9 25 2008rothacr
 
Adobe is from Mars, Microsoft is from Uranus. A look at two competing web st...
Adobe is from Mars, Microsoft is from Uranus.  A look at two competing web st...Adobe is from Mars, Microsoft is from Uranus.  A look at two competing web st...
Adobe is from Mars, Microsoft is from Uranus. A look at two competing web st...Eric Fickes
 
Introduction to silverlight
Introduction to silverlightIntroduction to silverlight
Introduction to silverlightmsarangam
 
Introduction to silverlight control 4
Introduction to silverlight control 4Introduction to silverlight control 4
Introduction to silverlight control 4msarangam
 
Silver Light for every one by Subodh
Silver Light for every one by SubodhSilver Light for every one by Subodh
Silver Light for every one by SubodhSubodh Pushpak
 
It's Time for Silverlight @iRajLal
It's Time for Silverlight @iRajLalIt's Time for Silverlight @iRajLal
It's Time for Silverlight @iRajLalRaj Lal
 
Session 2 - Silverlight Streaming, and Windows Live Search
Session 2 - Silverlight Streaming, and Windows Live SearchSession 2 - Silverlight Streaming, and Windows Live Search
Session 2 - Silverlight Streaming, and Windows Live Searchukdpe
 
Flex Remoting With WebORB v1.0
Flex Remoting With WebORB v1.0Flex Remoting With WebORB v1.0
Flex Remoting With WebORB v1.0guest642dd3
 
Introduction to Microsoft Silverlight
Introduction to Microsoft SilverlightIntroduction to Microsoft Silverlight
Introduction to Microsoft SilverlightGlen Gordon
 
Developing RIAs... 10 reasons to use Adobe Flex
Developing RIAs... 10 reasons to use Adobe FlexDeveloping RIAs... 10 reasons to use Adobe Flex
Developing RIAs... 10 reasons to use Adobe FlexMatthias Zeller
 
Silverlight Briefing Deck
Silverlight  Briefing  DeckSilverlight  Briefing  Deck
Silverlight Briefing Deckllangit
 
Re-use Your Skills and Code to Expand the Reach of Your Apps with Silverlight
Re-use Your Skills and Code to Expand the Reach of Your Apps with SilverlightRe-use Your Skills and Code to Expand the Reach of Your Apps with Silverlight
Re-use Your Skills and Code to Expand the Reach of Your Apps with SilverlightFrank La Vigne
 
Parallel minds silverlight
Parallel minds silverlightParallel minds silverlight
Parallel minds silverlightparallelminder
 

Similar a Silverlight Chapter 01 - Introduction (20)

Silverlight
SilverlightSilverlight
Silverlight
 
Uncovering Windows - Silverlight Seminar
Uncovering Windows - Silverlight SeminarUncovering Windows - Silverlight Seminar
Uncovering Windows - Silverlight Seminar
 
Tech Lunch 9 25 2008
Tech Lunch 9 25 2008Tech Lunch 9 25 2008
Tech Lunch 9 25 2008
 
Adobe is from Mars, Microsoft is from Uranus. A look at two competing web st...
Adobe is from Mars, Microsoft is from Uranus.  A look at two competing web st...Adobe is from Mars, Microsoft is from Uranus.  A look at two competing web st...
Adobe is from Mars, Microsoft is from Uranus. A look at two competing web st...
 
Introduction to silverlight
Introduction to silverlightIntroduction to silverlight
Introduction to silverlight
 
Introduction to silverlight control 4
Introduction to silverlight control 4Introduction to silverlight control 4
Introduction to silverlight control 4
 
Silver Light for every one by Subodh
Silver Light for every one by SubodhSilver Light for every one by Subodh
Silver Light for every one by Subodh
 
It's Time for Silverlight @iRajLal
It's Time for Silverlight @iRajLalIt's Time for Silverlight @iRajLal
It's Time for Silverlight @iRajLal
 
Session 2 - Silverlight Streaming, and Windows Live Search
Session 2 - Silverlight Streaming, and Windows Live SearchSession 2 - Silverlight Streaming, and Windows Live Search
Session 2 - Silverlight Streaming, and Windows Live Search
 
What is Adobe Flex ?
What is Adobe Flex  ?What is Adobe Flex  ?
What is Adobe Flex ?
 
Flex Remoting With WebORB v1.0
Flex Remoting With WebORB v1.0Flex Remoting With WebORB v1.0
Flex Remoting With WebORB v1.0
 
Introduction to Microsoft Silverlight
Introduction to Microsoft SilverlightIntroduction to Microsoft Silverlight
Introduction to Microsoft Silverlight
 
Developing RIAs... 10 reasons to use Adobe Flex
Developing RIAs... 10 reasons to use Adobe FlexDeveloping RIAs... 10 reasons to use Adobe Flex
Developing RIAs... 10 reasons to use Adobe Flex
 
Silverlight Briefing Deck
Silverlight  Briefing  DeckSilverlight  Briefing  Deck
Silverlight Briefing Deck
 
Re-use Your Skills and Code to Expand the Reach of Your Apps with Silverlight
Re-use Your Skills and Code to Expand the Reach of Your Apps with SilverlightRe-use Your Skills and Code to Expand the Reach of Your Apps with Silverlight
Re-use Your Skills and Code to Expand the Reach of Your Apps with Silverlight
 
Silverlight Training
Silverlight TrainingSilverlight Training
Silverlight Training
 
Parallel minds silverlight
Parallel minds silverlightParallel minds silverlight
Parallel minds silverlight
 
Flex RIA
Flex RIAFlex RIA
Flex RIA
 
Silverlight
SilverlightSilverlight
Silverlight
 
PHP and Silverlight
PHP and SilverlightPHP and Silverlight
PHP and Silverlight
 

Último

Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Visualising and forecasting stocks using Dash
Visualising and forecasting stocks using DashVisualising and forecasting stocks using Dash
Visualising and forecasting stocks using Dashnarutouzumaki53779
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 

Último (20)

Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Visualising and forecasting stocks using Dash
Visualising and forecasting stocks using DashVisualising and forecasting stocks using Dash
Visualising and forecasting stocks using Dash
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 

Silverlight Chapter 01 - Introduction

  • 1. Welcome! AppDev’s Silverlight 4 for Visual Studio 2010 Using Visual Basic Instructor: Bill Hatfield Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 2. Introducing Silverlight 4! Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 3. Objectives Introduce Silverlight Investigate XAML and the XAML designer in Visual Studio 2010 Learn about XAML controls, properties, and events Work with container controls, dependency properties, and the Grid control Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 4. Agenda Introducing Silverlight Introducing XAML and the Silverlight Designer Investigating XAML Introducing Content and Grid Controls Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 5. Introducing Silverlight Cross-browser, cross-platform plug-in Create rich interactive applications (RIAs) for the Web Originally seen as a competitor to Flash Lightweight runtime (under 5 MB) Based on XAML Quick demonstration: http://www.microsoft.com/silverlight Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 6. Copyright 2010, AppDev Products, LLC. All Rights Reserved. Why Silverlight? Delivers the best of both worlds: Leverages .NET Framework Creates rich Internet experiences Provides class library support for rapid development
  • 7. Why Silverlight? Beyond HTML Keeps users engaged Combines animation, video, vector graphics, perspective 3D, effects, features like Deep Zoom Fastest Web Experiences Put any CPU to work Multi-threading support Tap into 100+ Controls Silverlight allows you to skin controls using mark-up Easier to have controls fit your task or brand Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 8. Why Silverlight? Highest quality media Up to 1080p true HD-quality video Uses H.264 (MP4) or WMV with Smooth Streaming Mac, Windows, and Linux Works with every major operating system All major browsers Go out of Browser Can install applications on desktop Run apps seamlessly without connectivity Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 9. Evolution of Silverlight Silverlight 1 Support for scripting languages only Interesting layout capabilities Great for streaming videos Silverlight 2 Support for .NET Framework and CLR Data binding Isolated storage Support for calling services Cross-domain network access Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 10. Silverlight 3 Navigation Framework Build apps with multiple pages Navigation via links More controls and layout capabilities Modal windows Element-to-element binding Data validation Ability to run outside the browser Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 11. Silverlight 4 Printing support Several new controls, including DataGrid Enhanced data binding, including drag and drop “Toast” notification windows Offline DRM For trusted applications COM Interop Reading/writing user’s special folders New interface for requesting application privileges Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 12. Silverlight Development Tools Visual Studio 2008 (Silverlight 3) Download the Silverlight 3 Toolkit No visual designer Visual Studio 2010 (Silverlight 3 or 4) Build Silverlight applications out of the box Full tooling Download Silverlight 4 Expression Blend 3 (and now 4!) Powerful tool for building layout, animation, effects Bit of a learning curve (made for designers) Not free, but included in MSDN subscriptions Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 13. Getting Started Verify that Silverlight has been installed Navigate to: http://www.microsoft.com/silverlight/get-started/install/default.aspx Can also use Control Panel to verify version Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 14. Getting Started Build Silverlight solutions in Visual Studio Suggestion: Consider using Expression Blend for more complex styling, templating, animations, and so on Three types of Silverlight projects Silverlight Application template creates simple application Silverlight Navigation Application template provides a jumpstart for more sophisticated multi-page apps Silverlight Library creates DLL Makes it easier to partition logic and features Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 15. WPF vs. Silverlight Microsoft provides two technologies for client-side applications: WPF and Silverlight Both allow you to create client applications Both use XAML to design the interface WPF has entire .NET Framework behind it Silverlight works with a small subset of Framework Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 16. WPF vs. Silverlight WPF: Ships as part of .NET Framework (3.0 and later) Runs only on Windows (XP or better) Runs as a stand-alone Windows app or as a Web Browser app (XBAP) XBAPs require the .NET Framework on the client (where the browser is running) Browser compatibility: IE only in .NET 3.0; IE and Firefox in .NET 3.5 and later Provides richest functionality Full support for 3D graphics Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 17. WPF vs. Silverlight Silverlight: Ships independently; isn’t part of .NET Framework Is typically hosted in a Web browser Broad browser support including IE, Firefox, Safari Cross-platform - Runs on Windows, Mac, Linux clients Provides a subset of WPF’s features And only small subset of .NET Framework Which do you use? Depends on target audience, technological needs, preferred deployment Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 18. An Inconvenient Truth (or Two) Far more difficult to create a decent-looking application in XAML Because the bar is so much lower in other environments Developers creating applications in XAML generally create ugly applications Good XAML applications require graphic designers On the other hand… Far easier to create great-looking application Because Windows and Web forms are so limited Also check out Microsoft Expression Studio Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 19. Silverlight and XAML Silverlight and XAML: The same thing? XAML is XML-based grammar that can be used to declaratively define Silverlight applications Can also use Silverlight libraries and code the interface XAML <-> Silverlight libraries are not a one-to-one mapping Some names in used in creating a Silverlight interface in XAML don’t match exactly with the corresponding library class/collection/property names Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 20. Agenda Introducing Silverlight Introducing XAML and the Silverlight Designer Investigating XAML Introducing Content and Grid Controls Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 21. Introducing XAML Build Silverlight solutions in Visual Studio Use Expression Blend for sophisticated styling, templating, animations, and more Silverlight projects Silverlight Application template creates simple application Outputs XAP file, downloaded by the Silverlight runtime Silverlight Navigation Application template provides a jumpstart for multi-page apps Silverlight Library creates DLL Makes it easier to partition logic and features Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 22. Additional Silverlight 4 Projects Silverlight 4 adds more project types: Silverlight Business Application Includes login and membership WCF RIA Services Class Library Focus on Silverlight Application template in this course Visual Studio 2010 doesn’t include all Silverlight controls Download Silverlight Toolkit to get the rest http://www.codeplex.com/Silverlight Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 23. Your First Silverlight Application Pages 1-8 to 1-10 Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 24. Agenda Introducing Silverlight Introducing XAML and the Silverlight Designer Investigating XAML Introducing Content and Grid Controls Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 25. Investigating XAML XAML is simple But provides several different ways to set property values Simple Properties/Type Converters Complex Properties Markup Extensions Attached Properties Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 26. Simple Properties/Type Converters Dragging Button control onto design surface creates several properties Markup counts on Button class providing Content, Height, HorizontalAlignment, Margin, Name, VerticalAlignment, and Width properties Some properties are simple strings Content and Name properties Others are more complex Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 27. Type Converters Height and Width properties? Properties are numeric Markup supplies values as strings Along the line, some code must convert Works because Integer class provides built-in conversion from string Other properties even more complex: HorizontalAlignment and VerticalAlignment? Need to convert from string (Bottom, Center, Stretch, or Top; Center, Left, Right, Stretch) to enumerated values Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 28. Type Converters Margin adds own set of issues Can supply a single value (all four sides) Can supply two values (left/right and top/bottom) Can supply four values (left, top, right, bottom) Margin property is a Thickness structure Contains four integers Setting property calls constructor for Thickness structure Requires converter to read the comma-delimited string and convert to a call to the constructor Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 29. Complex Properties Type converters work well Some properties can’t be represented by single value Want to specify background of a Grid control as a linear gradient? Can’t represent the behavior with a single value Properties of elements that are themselves objects with properties require special care Represent as nested elements Named Parent.Property (Grid.Background) Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 30. DEMO Page 1-22: Complex Properties, Try It Out! Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 31. Markup Extensions Usually, standard XAML markup provides functionality you need Sometimes not possible to set property value at design time Some properties must be set dynamically, at runtime Need to use markup extension Allows you to set property in non-standard way Can specify markup extension as nested element, or as attribute As attribute, always surrounded with { } Indicating value supplied at runtime Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 32. Markup Extensions Declarative binding requires markup extension: Can also express using child element: Copyright 2010, AppDev Products, LLC. All Rights Reserved. Property= "{Binding ElementName=ObjectName, Path="PropertyName}" <Object.Property> <Binding ElementName="ObjectName", Path=PropertyName"/> </Object.Property>
  • 33. DEMO Markup extension/binding Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 34. Attached Properties Nest a control within a Grid Specify its row and column with Grid.Row and Grid.Column properties Where did these come from? Child control doesn't supply! Grid adds these to all its child controls In other words, they're attached properties Properties appear as properties of the class But they're defined in a different class (Grid, in this case) Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 35. Attached Properties Specific syntax: DefiningType.PropertyName Grid.Row Aren't actually properties Converted to method calls by compiler Defining class must provide GetPropertyName and SetPropertyName methods Grid.GetRow and Grid.SetRow Technique hides what's really going on Calling method in defining class? Does Grid keep track of all its children's coordinates? Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 36. Attached Properties Of course, Grid doesn't keep track of all its children's coordinates Child controls all inherit from DependencyObject Defined to maintain an unlimited number of dependency properties Parent (Grid) maintains a single instance of a field for each property Grid.RowProperty for Grid.Row, for example Child maintains its own value for that property Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 37. Attached Properties Calling parent control's GetPropertyName and SetPropertyNamemethods equivalent to calling GetValue and SetValue methods of child object To retrieve Grid.Row property of TextBox named DemoTextBox, use expression like: Copyright 2010, AppDev Products, LLC. All Rights Reserved. DemoTextBox.GetValue(Grid.RowProperty)
  • 38. Agenda Introducing Silverlight Introducing XAML and the Silverlight Designer Investigating XAML Introducing Content and Grid Controls Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 39. Content and Grid Controls Many controls inherit from ContentControl (including Button) and can contain other controls Button with image and text? No problem! ListBox containing a bunch of TextBox controls? No problem! Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 40. Working with Layout Controls Several controls useful for laying out other controls DockPanel Allocates an edge for each child control Useful for defining rough layout StackPanel Stacks children horizontally or vertically Useful internal to other controls (Button, for example) Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 41. Working with Layout Controls Grid Arranges children in a grid No need for fixed sizes or positions Rescales when resized Canvas No layout logic Manually control each aspect of layout Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 42. List Box as Container DEMO Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 43. Working with the Grid Control DEMO Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 44. Dependency Properties In standard .NET code, property is defined using two procedures “setter” and “getter” More complex mechanism here Workflow uses same mechanism Dependency properties allow for: Styling Automatic data binding Animation Change notification and more… Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 45. DependencyObject Class DependencyProperty class acts as base for the properties DependencyObject is base for classes that can consume and expose dependency properties XAML classes expose far more properties than the corresponding prior classes Need some internal plumbing to handle Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 46. Investigating DependencyProperty .NET maintains internal dictionary of classes and the properties they expose DependencyProperty instance defined as a static/shared member of a class In constructor, code registers property, its type, and hosting class with .NET Can optionally create standard .NET property that wraps up the dependency property Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 47. Declaring the Property Copyright 2010, AppDev Products, LLC. All Rights Reserved. VB: Public Shared IsAvailableProperty As DependencyProperty C#: public static DependencyProperty IsAvailableProperty;
  • 48. In Constructor Copyright 2010, AppDev Products, LLC. All Rights Reserved. [Visual Basic] MyClass.IsAvailableProperty = _ DependencyProperty.Register("IsAvailable", _ GetType(Boolean), GetType(MyClass)) [C#] MyClass.IsAvailableProperty = DependencyProperty.Register("IsAvailable", typeof(bool), typeof(MyClass))
  • 49. Property Wrapper Copyright 2010, AppDev Products, LLC. All Rights Reserved. [Visual Basic] Public Property IsAvailable() As Boolean Get Return _ CType(GetValue(MyClass.IsAvailableProperty), Boolean) End Get Set(ByVal value As Boolean) SetValue(MyClass.IsAvailableProperty, value) End SetEnd Property
  • 50. Property Wrapper Copyright 2010, AppDev Products, LLC. All Rights Reserved. [C#] public bool IsAvailable{ get { return (bool) GetValue(MyClass.IsAvailableProperty); } set { SetValue(MyClass.IsAvailableProperty, value) }}
  • 51. Using Attached Properties Button control doesn’t expose Grid.Column or Grid.Row Yet these attributes exist in the XAML markup These are attached properties Properties added by container, when hosted Retrieve and set using DependencyObject.GetValue and DependencyObject.SetValue Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 52. Working with Attached Properties Copyright 2010, AppDev Products, LLC. All Rights Reserved. [Visual Basic] Dim row As Integer = CType(DemoButton.GetValue(Grid.RowProperty), Integer) DemoButton.SetValue(Grid.RowProperty, row + 1) [C#] int row = (int)DemoButton.GetValue(Grid.RowProperty); DemoButton.SetValue(Grid.RowProperty, row + 1);
  • 53. Interacting with the Grid Add code to move button to new row Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 54. Running Out of Browser Silverlight applications distributed through browser But applications can be run locally: no connection! Even when run locally Silverlight apps use only small subset of .NET Framework Apps are still sandboxed Can’t do anything destructive unless granted permission explicitly No connectivity required Simple to install and uninstall Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 55. Running Out of Browser DEMO Copyright 2010, AppDev Products, LLC. All Rights Reserved.