SlideShare a Scribd company logo
Welcome!AppDev’sSilverlight 4 for Visual Studio 2010 Using Visual BasicInstructor: Bill HatfieldCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
Introducing Silverlight 4!Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
ObjectivesIntroduce SilverlightInvestigate XAML and the XAML designer in Visual Studio 2010Learn about XAML controls, properties, and eventsWork with container controls, dependency properties, and the Grid controlCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
AgendaIntroducing SilverlightIntroducing XAML and the Silverlight DesignerInvestigating XAMLIntroducing Content and Grid ControlsCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
Introducing SilverlightCross-browser, cross-platform plug-inCreate rich interactive applications (RIAs) for the WebOriginally seen as a competitor to Flash Lightweight runtime (under 5 MB)Based on XAMLQuick demonstration:http://www.microsoft.com/silverlightCopyright 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 FrameworkCreates rich Internet experiencesProvides class library support for rapid development
Why Silverlight?Beyond HTMLKeeps users engaged Combines animation, video, vector graphics, perspective 3D, effects, features like Deep ZoomFastest Web ExperiencesPut any CPU to workMulti-threading supportTap into 100+ ControlsSilverlight allows you to skin controls using mark-upEasier to have controls fit your task or brandCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
Why Silverlight?Highest quality mediaUp to 1080p true HD-quality videoUses H.264 (MP4) or WMV with Smooth StreamingMac, Windows, and LinuxWorks with every major operating systemAll major browsersGo out of BrowserCan install applications on desktopRun apps seamlessly without connectivityCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
Evolution of SilverlightSilverlight 1Support for scripting languages onlyInteresting layout capabilitiesGreat for streaming videosSilverlight 2Support for .NET Framework and CLRData bindingIsolated storageSupport for calling servicesCross-domain network accessCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
Silverlight 3Navigation FrameworkBuild apps with multiple pagesNavigation via linksMore controls and layout capabilitiesModal windowsElement-to-element bindingData validationAbility to run outside the browserCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
Silverlight 4Printing supportSeveral new controls, including DataGridEnhanced data binding, including drag and drop“Toast” notification windowsOffline DRMFor trusted applicationsCOM InteropReading/writing user’s special foldersNew interface for requesting application privilegesCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
Silverlight Development ToolsVisual Studio 2008 (Silverlight 3)Download the Silverlight 3 ToolkitNo visual designerVisual Studio 2010 (Silverlight 3 or 4)Build Silverlight applications out of the boxFull toolingDownload Silverlight 4Expression Blend 3 (and now 4!)Powerful tool for building layout, animation, effectsBit of a learning curve (made for designers)Not free, but included in MSDN subscriptionsCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
Getting StartedVerify that Silverlight has been installedNavigate to:http://www.microsoft.com/silverlight/get-started/install/default.aspxCan also use Control Panel to verify versionCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
Getting StartedBuild Silverlight solutions in Visual StudioSuggestion: Consider using Expression Blend for more complex styling, templating, animations, and so onThree types of Silverlight projectsSilverlight Application template creates simple applicationSilverlight Navigation Application template provides a jumpstart for more sophisticated multi-page  appsSilverlight Library creates DLL Makes it easier to partition logic and featuresCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
WPF vs. SilverlightMicrosoft provides two technologies for client-side applications: WPF and SilverlightBoth allow you to create client applicationsBoth use XAML to design the interfaceWPF has entire .NET Framework behind itSilverlight works with a small subset of FrameworkCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
WPF vs. SilverlightWPF: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 laterProvides richest functionalityFull support for 3D graphicsCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
WPF vs. SilverlightSilverlight:Ships independently; isn’t part of .NET FrameworkIs typically hosted in a Web browserBroad browser support including IE, Firefox, SafariCross-platform - Runs on Windows, Mac, Linux clientsProvides a subset of WPF’s featuresAnd only small subset of .NET FrameworkWhich do you use?Depends on target audience, technological needs, preferred deploymentCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
An Inconvenient Truth (or Two)Far more difficult to create a decent-looking application in XAMLBecause the bar is so much lower in other environmentsDevelopers creating applications in XAML generally create ugly applicationsGood XAML applications require graphic designersOn the other hand…Far easier to create great-looking application Because Windows and Web forms are so limited Also check out Microsoft Expression StudioCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
Silverlight and XAMLSilverlight and XAML: The same thing?XAML is XML-based grammar that can be used to declaratively define Silverlight applicationsCan also use Silverlight libraries and code the interfaceXAML <-> Silverlight libraries are not a one-to-one mappingSome names in used in creating a Silverlight interface in XAML don’t match exactly with the corresponding library class/collection/property namesCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
AgendaIntroducing SilverlightIntroducing XAML and the Silverlight DesignerInvestigating XAMLIntroducing Content and Grid ControlsCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
Introducing XAMLBuild Silverlight solutions in Visual StudioUse Expression Blend for sophisticated styling, templating, animations, and moreSilverlight projectsSilverlight Application template creates simple applicationOutputs XAP file, downloaded by the Silverlight runtimeSilverlight Navigation Application template provides a jumpstart for multi-page appsSilverlight Library creates DLL Makes it easier to partition logic and featuresCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
Additional Silverlight 4 ProjectsSilverlight 4 adds more project types:Silverlight Business ApplicationIncludes login and membership WCF RIA Services Class LibraryFocus on Silverlight Application template in this courseVisual Studio 2010 doesn’t include all Silverlight controlsDownload Silverlight Toolkit to get the resthttp://www.codeplex.com/SilverlightCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
Your First Silverlight ApplicationPages 1-8 to 1-10Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
AgendaIntroducing SilverlightIntroducing XAML and the Silverlight DesignerInvestigating XAMLIntroducing Content and Grid ControlsCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
Investigating XAMLXAML is simpleBut provides several different ways to set property valuesSimple Properties/Type ConvertersComplex PropertiesMarkup ExtensionsAttached PropertiesCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
Simple Properties/Type ConvertersDragging Button control onto design surface creates several propertiesMarkup counts on Button class providing Content, Height, HorizontalAlignment, Margin, Name, VerticalAlignment, and Width propertiesSome properties are simple stringsContent and Name propertiesOthers are more complexCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
Type ConvertersHeight and Width properties?Properties are numericMarkup supplies values as stringsAlong the line, some code must convertWorks because Integer class provides built-in conversion from stringOther properties even more complex:HorizontalAlignment and VerticalAlignment?Need to convert from string (Bottom, Center, Stretch, or Top; Center, Left, Right, Stretch) to enumerated valuesCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
Type ConvertersMargin adds own set of issuesCan 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 structureContains four integersSetting property calls constructor for Thickness structureRequires converter to read the comma-delimited string and convert to a call to the constructorCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
Complex PropertiesType converters work wellSome properties can’t be represented by single valueWant to specify background of a Grid control as a linear gradient?Can’t represent the behavior with a single valueProperties of elements that are themselves objects with properties require special careRepresent as nested elements Named Parent.Property (Grid.Background)Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
DEMOPage 1-22: Complex Properties, Try It Out!Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Markup ExtensionsUsually, standard XAML markup provides functionality you needSometimes not possible to set property value at design timeSome properties must be set dynamically, at runtimeNeed to use markup extensionAllows you to set property in non-standard wayCan specify markup extension as nested element, or as attributeAs attribute, always surrounded with {  }Indicating value supplied at runtimeCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
Markup ExtensionsDeclarative 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>
DEMOMarkup extension/bindingCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
Attached PropertiesNest a control within a GridSpecify its row and column with Grid.Row and Grid.Column propertiesWhere did these come from? Child control doesn't supply!Grid adds these to all its child controlsIn other words, they're attached propertiesProperties appear as properties of the classBut they're defined in a different class (Grid, in this case)Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Attached PropertiesSpecific syntax:DefiningType.PropertyNameGrid.RowAren't actually propertiesConverted to method calls by compilerDefining class must provide GetPropertyName and SetPropertyName methodsGrid.GetRow and Grid.SetRowTechnique hides what's really going onCalling method in defining class?Does Grid keep track of all its children's coordinates?Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Attached PropertiesOf course, Grid doesn't keep track of all its children's coordinatesChild controls all inherit from DependencyObjectDefined to maintain an unlimited number of dependency propertiesParent (Grid) maintains a single instance of a field for each propertyGrid.RowProperty for Grid.Row, for exampleChild maintains its own value for that propertyCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
Attached PropertiesCalling parent control's GetPropertyName and SetPropertyNamemethods equivalent to calling GetValue and SetValue methods of child objectTo retrieve Grid.Row property of TextBox named DemoTextBox, use expression like:Copyright 2010, AppDev Products, LLC.    All Rights Reserved.DemoTextBox.GetValue(Grid.RowProperty)
AgendaIntroducing SilverlightIntroducing XAML and the Silverlight DesignerInvestigating XAMLIntroducing Content and Grid ControlsCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
Content and Grid ControlsMany controls inherit from ContentControl (including Button) and can contain other controlsButton 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 ControlsSeveral controls useful for laying out other controlsDockPanelAllocates an edge for each child controlUseful for defining rough layoutStackPanelStacks children horizontally or verticallyUseful internal to other controls (Button, for example)Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
Working with Layout ControlsGridArranges children in a gridNo need for fixed sizes or positionsRescales when resizedCanvasNo layout logicManually control each aspect of layoutCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
List Box as ContainerDEMOCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
Working with the Grid ControlDEMOCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
Dependency PropertiesIn standard .NET code, property is defined using two procedures“setter” and “getter”More complex mechanism hereWorkflow uses same mechanismDependency properties allow for:StylingAutomatic data bindingAnimationChange notificationand more…Copyright 2010, AppDev Products, LLC.    All Rights Reserved.
DependencyObject ClassDependencyProperty class acts as base for the propertiesDependencyObject is base for classes that can consume and expose dependency propertiesXAML classes expose far more properties than the corresponding prior classesNeed some internal plumbing to handleCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
Investigating DependencyProperty.NET maintains internal dictionary of classes and the properties they exposeDependencyProperty instance defined as a static/shared member of a classIn constructor, code registers property, its type, and hosting class with .NETCan optionally create standard .NET property that wraps up the dependency propertyCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
Declaring the PropertyCopyright 2010, AppDev Products, LLC.    All Rights Reserved.VB: Public Shared IsAvailableProperty As DependencyPropertyC#: public static DependencyProperty IsAvailableProperty;
In ConstructorCopyright 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 WrapperCopyright 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 WrapperCopyright 2010, AppDev Products, LLC.    All Rights Reserved.[C#]public bool IsAvailable{  get {     return (bool) GetValue(MyClass.IsAvailableProperty); }  set { SetValue(MyClass.IsAvailableProperty, value) }}
Using Attached PropertiesButton control doesn’t expose Grid.Column or Grid.RowYet these attributes exist in the XAML markupThese are attached propertiesProperties added by container, when hostedRetrieve and set using DependencyObject.GetValue and DependencyObject.SetValueCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
Working with Attached PropertiesCopyright 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 GridAdd code to move button to new rowCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
Running Out of BrowserSilverlight applications distributed through browserBut applications can be run locally: no connection!Even when run locallySilverlight apps use only small subset of .NET FrameworkApps are still sandboxedCan’t do anything destructive unless granted permission explicitlyNo connectivity requiredSimple to install and uninstallCopyright 2010, AppDev Products, LLC.    All Rights Reserved.
Running Out of BrowserDEMOCopyright 2010, AppDev Products, LLC.    All Rights Reserved.

More Related Content

PPT
Best Practices Configuring And Developing Share Point Solutions
PDF
Michael Adobe Flex Java 1 London
PPT
Adobe® Flex™
PPT
Flex vs HTML5
PPTX
Intro to VS 2010 & .Net 4.0
PDF
Html5 aria-css-ibm-csun-2016
PDF
Bn1001 demo ppt advance dot net
PPT
WebSphere Community Edition
Best Practices Configuring And Developing Share Point Solutions
Michael Adobe Flex Java 1 London
Adobe® Flex™
Flex vs HTML5
Intro to VS 2010 & .Net 4.0
Html5 aria-css-ibm-csun-2016
Bn1001 demo ppt advance dot net
WebSphere Community Edition

What's hot (18)

PDF
IBM WebSphere Portal References Education
PPT
Flex3
PDF
Adobe AIR Programming to Desktop and Mobile
PPT
Adobe's RIA Technologies (non technical)
DOCX
Beginners introduction to asp.net
PDF
Max 2010: Having Fun Flex4 Layouts
PDF
Enrique Duvos: Adobe RIA Platform
PDF
Real World SharePoint Framework and Azure Services
PPTX
Uncovering the Latest in SharePoint Development
PPT
MSDN Unleashed: WPF Demystified
PDF
SPCA2013 - Building Windows Client Applications for SharePoint 2013
PPTX
Move past bootstrap and build our lightweight responsive framework w.v1.2
PPT
Flex And Ria
PPT
IBM WebSphere Portal
PDF
Hello Gumbo
PPT
San Francisco PHP Meetup Presentation on Zend Framework
PPT
WebSphere Portal Business Overview
PDF
Developing service component architecture applications using rational applica...
IBM WebSphere Portal References Education
Flex3
Adobe AIR Programming to Desktop and Mobile
Adobe's RIA Technologies (non technical)
Beginners introduction to asp.net
Max 2010: Having Fun Flex4 Layouts
Enrique Duvos: Adobe RIA Platform
Real World SharePoint Framework and Azure Services
Uncovering the Latest in SharePoint Development
MSDN Unleashed: WPF Demystified
SPCA2013 - Building Windows Client Applications for SharePoint 2013
Move past bootstrap and build our lightweight responsive framework w.v1.2
Flex And Ria
IBM WebSphere Portal
Hello Gumbo
San Francisco PHP Meetup Presentation on Zend Framework
WebSphere Portal Business Overview
Developing service component architecture applications using rational applica...
Ad

Similar to SilverlightCh01 (20)

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

Recently uploaded (20)

PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Electronic commerce courselecture one. Pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Approach and Philosophy of On baking technology
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Modernizing your data center with Dell and AMD
PDF
Empathic Computing: Creating Shared Understanding
PDF
cuic standard and advanced reporting.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Encapsulation theory and applications.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
“AI and Expert System Decision Support & Business Intelligence Systems”
Electronic commerce courselecture one. Pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Approach and Philosophy of On baking technology
Per capita expenditure prediction using model stacking based on satellite ima...
Modernizing your data center with Dell and AMD
Empathic Computing: Creating Shared Understanding
cuic standard and advanced reporting.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Understanding_Digital_Forensics_Presentation.pptx
Encapsulation theory and applications.pdf

SilverlightCh01

  • 1. Welcome!AppDev’sSilverlight 4 for Visual Studio 2010 Using Visual BasicInstructor: Bill HatfieldCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 2. Introducing Silverlight 4!Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 3. ObjectivesIntroduce SilverlightInvestigate XAML and the XAML designer in Visual Studio 2010Learn about XAML controls, properties, and eventsWork with container controls, dependency properties, and the Grid controlCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 4. AgendaIntroducing SilverlightIntroducing XAML and the Silverlight DesignerInvestigating XAMLIntroducing Content and Grid ControlsCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 5. Introducing SilverlightCross-browser, cross-platform plug-inCreate rich interactive applications (RIAs) for the WebOriginally seen as a competitor to Flash Lightweight runtime (under 5 MB)Based on XAMLQuick demonstration:http://www.microsoft.com/silverlightCopyright 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 FrameworkCreates rich Internet experiencesProvides class library support for rapid development
  • 7. Why Silverlight?Beyond HTMLKeeps users engaged Combines animation, video, vector graphics, perspective 3D, effects, features like Deep ZoomFastest Web ExperiencesPut any CPU to workMulti-threading supportTap into 100+ ControlsSilverlight allows you to skin controls using mark-upEasier to have controls fit your task or brandCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 8. Why Silverlight?Highest quality mediaUp to 1080p true HD-quality videoUses H.264 (MP4) or WMV with Smooth StreamingMac, Windows, and LinuxWorks with every major operating systemAll major browsersGo out of BrowserCan install applications on desktopRun apps seamlessly without connectivityCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 9. Evolution of SilverlightSilverlight 1Support for scripting languages onlyInteresting layout capabilitiesGreat for streaming videosSilverlight 2Support for .NET Framework and CLRData bindingIsolated storageSupport for calling servicesCross-domain network accessCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 10. Silverlight 3Navigation FrameworkBuild apps with multiple pagesNavigation via linksMore controls and layout capabilitiesModal windowsElement-to-element bindingData validationAbility to run outside the browserCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 11. Silverlight 4Printing supportSeveral new controls, including DataGridEnhanced data binding, including drag and drop“Toast” notification windowsOffline DRMFor trusted applicationsCOM InteropReading/writing user’s special foldersNew interface for requesting application privilegesCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 12. Silverlight Development ToolsVisual Studio 2008 (Silverlight 3)Download the Silverlight 3 ToolkitNo visual designerVisual Studio 2010 (Silverlight 3 or 4)Build Silverlight applications out of the boxFull toolingDownload Silverlight 4Expression Blend 3 (and now 4!)Powerful tool for building layout, animation, effectsBit of a learning curve (made for designers)Not free, but included in MSDN subscriptionsCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 13. Getting StartedVerify that Silverlight has been installedNavigate to:http://www.microsoft.com/silverlight/get-started/install/default.aspxCan also use Control Panel to verify versionCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 14. Getting StartedBuild Silverlight solutions in Visual StudioSuggestion: Consider using Expression Blend for more complex styling, templating, animations, and so onThree types of Silverlight projectsSilverlight Application template creates simple applicationSilverlight Navigation Application template provides a jumpstart for more sophisticated multi-page appsSilverlight Library creates DLL Makes it easier to partition logic and featuresCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 15. WPF vs. SilverlightMicrosoft provides two technologies for client-side applications: WPF and SilverlightBoth allow you to create client applicationsBoth use XAML to design the interfaceWPF has entire .NET Framework behind itSilverlight works with a small subset of FrameworkCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 16. WPF vs. SilverlightWPF: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 laterProvides richest functionalityFull support for 3D graphicsCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 17. WPF vs. SilverlightSilverlight:Ships independently; isn’t part of .NET FrameworkIs typically hosted in a Web browserBroad browser support including IE, Firefox, SafariCross-platform - Runs on Windows, Mac, Linux clientsProvides a subset of WPF’s featuresAnd only small subset of .NET FrameworkWhich do you use?Depends on target audience, technological needs, preferred deploymentCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 18. An Inconvenient Truth (or Two)Far more difficult to create a decent-looking application in XAMLBecause the bar is so much lower in other environmentsDevelopers creating applications in XAML generally create ugly applicationsGood XAML applications require graphic designersOn the other hand…Far easier to create great-looking application Because Windows and Web forms are so limited Also check out Microsoft Expression StudioCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 19. Silverlight and XAMLSilverlight and XAML: The same thing?XAML is XML-based grammar that can be used to declaratively define Silverlight applicationsCan also use Silverlight libraries and code the interfaceXAML <-> Silverlight libraries are not a one-to-one mappingSome names in used in creating a Silverlight interface in XAML don’t match exactly with the corresponding library class/collection/property namesCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 20. AgendaIntroducing SilverlightIntroducing XAML and the Silverlight DesignerInvestigating XAMLIntroducing Content and Grid ControlsCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 21. Introducing XAMLBuild Silverlight solutions in Visual StudioUse Expression Blend for sophisticated styling, templating, animations, and moreSilverlight projectsSilverlight Application template creates simple applicationOutputs XAP file, downloaded by the Silverlight runtimeSilverlight Navigation Application template provides a jumpstart for multi-page appsSilverlight Library creates DLL Makes it easier to partition logic and featuresCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 22. Additional Silverlight 4 ProjectsSilverlight 4 adds more project types:Silverlight Business ApplicationIncludes login and membership WCF RIA Services Class LibraryFocus on Silverlight Application template in this courseVisual Studio 2010 doesn’t include all Silverlight controlsDownload Silverlight Toolkit to get the resthttp://www.codeplex.com/SilverlightCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 23. Your First Silverlight ApplicationPages 1-8 to 1-10Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 24. AgendaIntroducing SilverlightIntroducing XAML and the Silverlight DesignerInvestigating XAMLIntroducing Content and Grid ControlsCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 25. Investigating XAMLXAML is simpleBut provides several different ways to set property valuesSimple Properties/Type ConvertersComplex PropertiesMarkup ExtensionsAttached PropertiesCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 26. Simple Properties/Type ConvertersDragging Button control onto design surface creates several propertiesMarkup counts on Button class providing Content, Height, HorizontalAlignment, Margin, Name, VerticalAlignment, and Width propertiesSome properties are simple stringsContent and Name propertiesOthers are more complexCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 27. Type ConvertersHeight and Width properties?Properties are numericMarkup supplies values as stringsAlong the line, some code must convertWorks because Integer class provides built-in conversion from stringOther properties even more complex:HorizontalAlignment and VerticalAlignment?Need to convert from string (Bottom, Center, Stretch, or Top; Center, Left, Right, Stretch) to enumerated valuesCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 28. Type ConvertersMargin adds own set of issuesCan 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 structureContains four integersSetting property calls constructor for Thickness structureRequires converter to read the comma-delimited string and convert to a call to the constructorCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 29. Complex PropertiesType converters work wellSome properties can’t be represented by single valueWant to specify background of a Grid control as a linear gradient?Can’t represent the behavior with a single valueProperties of elements that are themselves objects with properties require special careRepresent as nested elements Named Parent.Property (Grid.Background)Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 30. DEMOPage 1-22: Complex Properties, Try It Out!Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 31. Markup ExtensionsUsually, standard XAML markup provides functionality you needSometimes not possible to set property value at design timeSome properties must be set dynamically, at runtimeNeed to use markup extensionAllows you to set property in non-standard wayCan specify markup extension as nested element, or as attributeAs attribute, always surrounded with { }Indicating value supplied at runtimeCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 32. Markup ExtensionsDeclarative 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. DEMOMarkup extension/bindingCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 34. Attached PropertiesNest a control within a GridSpecify its row and column with Grid.Row and Grid.Column propertiesWhere did these come from? Child control doesn't supply!Grid adds these to all its child controlsIn other words, they're attached propertiesProperties appear as properties of the classBut they're defined in a different class (Grid, in this case)Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 35. Attached PropertiesSpecific syntax:DefiningType.PropertyNameGrid.RowAren't actually propertiesConverted to method calls by compilerDefining class must provide GetPropertyName and SetPropertyName methodsGrid.GetRow and Grid.SetRowTechnique hides what's really going onCalling method in defining class?Does Grid keep track of all its children's coordinates?Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 36. Attached PropertiesOf course, Grid doesn't keep track of all its children's coordinatesChild controls all inherit from DependencyObjectDefined to maintain an unlimited number of dependency propertiesParent (Grid) maintains a single instance of a field for each propertyGrid.RowProperty for Grid.Row, for exampleChild maintains its own value for that propertyCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 37. Attached PropertiesCalling parent control's GetPropertyName and SetPropertyNamemethods equivalent to calling GetValue and SetValue methods of child objectTo retrieve Grid.Row property of TextBox named DemoTextBox, use expression like:Copyright 2010, AppDev Products, LLC. All Rights Reserved.DemoTextBox.GetValue(Grid.RowProperty)
  • 38. AgendaIntroducing SilverlightIntroducing XAML and the Silverlight DesignerInvestigating XAMLIntroducing Content and Grid ControlsCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 39. Content and Grid ControlsMany controls inherit from ContentControl (including Button) and can contain other controlsButton 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 ControlsSeveral controls useful for laying out other controlsDockPanelAllocates an edge for each child controlUseful for defining rough layoutStackPanelStacks children horizontally or verticallyUseful internal to other controls (Button, for example)Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 41. Working with Layout ControlsGridArranges children in a gridNo need for fixed sizes or positionsRescales when resizedCanvasNo layout logicManually control each aspect of layoutCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 42. List Box as ContainerDEMOCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 43. Working with the Grid ControlDEMOCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 44. Dependency PropertiesIn standard .NET code, property is defined using two procedures“setter” and “getter”More complex mechanism hereWorkflow uses same mechanismDependency properties allow for:StylingAutomatic data bindingAnimationChange notificationand more…Copyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 45. DependencyObject ClassDependencyProperty class acts as base for the propertiesDependencyObject is base for classes that can consume and expose dependency propertiesXAML classes expose far more properties than the corresponding prior classesNeed some internal plumbing to handleCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 46. Investigating DependencyProperty.NET maintains internal dictionary of classes and the properties they exposeDependencyProperty instance defined as a static/shared member of a classIn constructor, code registers property, its type, and hosting class with .NETCan optionally create standard .NET property that wraps up the dependency propertyCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 47. Declaring the PropertyCopyright 2010, AppDev Products, LLC. All Rights Reserved.VB: Public Shared IsAvailableProperty As DependencyPropertyC#: public static DependencyProperty IsAvailableProperty;
  • 48. In ConstructorCopyright 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 WrapperCopyright 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 WrapperCopyright 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 PropertiesButton control doesn’t expose Grid.Column or Grid.RowYet these attributes exist in the XAML markupThese are attached propertiesProperties added by container, when hostedRetrieve and set using DependencyObject.GetValue and DependencyObject.SetValueCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 52. Working with Attached PropertiesCopyright 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 GridAdd code to move button to new rowCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 54. Running Out of BrowserSilverlight applications distributed through browserBut applications can be run locally: no connection!Even when run locallySilverlight apps use only small subset of .NET FrameworkApps are still sandboxedCan’t do anything destructive unless granted permission explicitlyNo connectivity requiredSimple to install and uninstallCopyright 2010, AppDev Products, LLC. All Rights Reserved.
  • 55. Running Out of BrowserDEMOCopyright 2010, AppDev Products, LLC. All Rights Reserved.