Thursday 27 December 2012

The WPF Tutorial Objectives:



WPF Tutorial
The WPF Tutorial Objectives:
•        Understand the motivation behind WPF
•        Examine the various ‘flavors’ of WPF applications
•        Overview the services provided by WPF
•        Examine the core WPF assemblies and namespaces
•        Work with the Window and Application class types
•        Learn the syntax of XAML
•        Understand the XAML / code relationship
•        Survey the core WPF control types
•        Review the WPF control programming model
•        Learn to position controls using layout managers
•        Understand the role of WPF control commands
•        Understand the scope of the WPF documents API
•        Distinguish between fixed documents and flow documents
•        Populate a document with in-line and block elements
•        Work with the WPF document APIs



Every few years or so, Microsoft introduces a new GUI toolkit. Since the release of .NET 3.0, the latest 
toolkit is Windows Presentation Foundation (WPF).  In this introduction, you will understand the motivation 
behind WPF, learn the syntax of XAML, examine the core programming model, and survey several WPF 
services. Also, you will overview the WPF support provided by Visual Studio and Expression Blend. As you 
would expect, this chapter provides a foundation for the remainder of the class.

The Motivation Behind WPF       
                                                    
Historically speaking, building a desktop UI under the Windows OS involved using a handful of key services:
      •        
User32: Provided the code required to create windows, controls, and application infrastructure.
      •        
GDI: Provided a framework for rendering 2D graphical data.
      •      
  DirectX: If an application required high-performance graphical rendering (multimedia applications,
                video games, rich interactive front ends, and so on), DirectX was the way to do so.

Although Windows programmers could make use of these services using C or C++, many UI toolkits were 
introduced over the years.  VB6, MFC, Windows Forms, GDI+, and so on.  Each one of them was simply a 
wrapper around User32 / GDI.  These toolkits still viewed DirectX as an ‘external’ service.

Windows Presentation Foundation (WPF) is a brand-new GUI toolkit that shipped beginning with NET 3.0.
The core WPF object model is similar, but not identical to, Windows Forms.  The release of WPF does not 
imply that Windows Forms is obsolete. In fact, the .NET platform will support this API for years to come.

Like other .NET 3.0 / 3.5 technologies, WPF can be used under XP, Vista, or Windows Server 2003 and 
higher.  The .NET 3.0 / 3.5 libraries ship automatically with Vista.  Other OSs will require a separate 
installation of the 3.0 / 3.5 libraries through the freely downloadable .NET runtime installation program (the 
3.5 version of dotnetfx.exe).

Before the release of WPF, UI developers were forced to master a number of related, but ultimately 
independent, APIs.  This required developers to ‘switch gears’ when moving from one task (e.g., building a 
main window) to another (e.g., 3D graphical rendering).  The end result was a very
 asymmetrical way to 
program.

Consider the GUI development world before .NET 3.0:























With the release of WPF, things have improved considerably.  You now have a single 
symmetrical manner in 
which to interact with the necessary GUI infrastructure. Consider the GUI development world as of .NET 
3.0 and higher:























Beyond offering a unified programming model, WPF also provides a clear 
separation of concerns.  It is now 
possible to separate the look and feel of a GUI application from the programming logic that drives it.         
This is achieved using an XML-based grammar termed XAML (‘zam-el’).  While most WPF applications will 
make use of XAML, doing so is entirely optional.

This separation of concerns (via XAML) makes it much simpler for graphical designers to build very rich, 
professional UIs.  Graphically minded individuals can use dedicated design tools such as 
Microsoft 
Expression Blend
 to generate the XAML.  These XAML files can then be passed to the programming team 
to add logic to drive the UI (event handlers, method overrides, and so on).  Better yet, a Microsoft Blend 
project uses exactly the same format as a Visual Studio project.

Beyond the introduction of XAML, WPF also provides a good number of integrated services, including (but 
not limited to) the following:

     •        A number of layout managers that provide full control over placement and repositioning of content.
     •        A built-in style engine, which allows you to define ‘themes’ for a WPF application.
     •        Native use of vector graphics, which allows an image to be automatically resized to fit the size and
              resolution of the screen hosting the application.
     •        A rich typography API such as support for XPS (XML Paper Specification) documents, fixed
              documents (WYSIWYG), flow documents, and document annotations (e.g., a Sticky Notes API).
     •        Integrated 2D and 3D rendering services / animation services, which leverage DirectX for hardware
              acceleration. In fact, all rendering, even the rendering of UI elements (buttons, and so on) is
              preformed via DirectX.
     •        Support for audio and video media.

Overall, WPF can be considered a ‘supercharged’ UI framework.  WPF is extremely useful when you need to 
build highly interactive, stylized front ends.  Real-time rotation of 3D bar charts, spinning a portion of a UI 
to a 45-degree angle, and dynamic shadowing on a rendered image are all possible.

Consider the following WPF application (an example project from Expression Blend). Clicking on any 
buttons on the bottom of the application will rotate and animate a motorcycle prototype. Each button has a 
custom animation, performed when the cursor travels over the surface. While all of this could be done without 
WPF, doing so would require a considerable amount of complex code.

























Because WPF applications are so graphically intensive, a production-level WPF application will require the 
aid of a professional graphic designer.  You may agree that most .NET programmers are not the best of 
artists.  Likewise, most artists are not the best of .NET programmers. Using XAML and tools such as Visual 
Studio and MS Expression Blend, each part of the team can use dedicated tools, thus increasing efficiency in 
development.  Remember that the same Visual Studio WPF application can be opened in Expression Blend.

This is not to suggest that you cannot use WPF to build ‘traditional’ GUIs (gray push buttons, a grid, a menu 
system, and so on).  You can certainly use WPF to build traditional business applications.   However, this 
API is strongly geared for next-generation GUI applications. WPF is closer to the ‘Hollywood vision’ of 
what computer applications should look like (e.g., 3D spinning e-mail messages, glowing animated blocks of 
text, and the like).

GUI applications that do not need this extra horsepower still gain benefits (separation of concerns, object 
model integration, and more).  However, in some cases, Windows Forms may provide a more direct 
development path.  Be aware that some of these ‘supercharged’ graphic features of WPF will require a ‘semi-
supercharged’ machine to run them at an acceptable rate.  Testing is always a good idea.
Table of Contents
Copyright (c) 2008.  Intertech, Inc. All Rights Reserved.  This information is to be used exclusively as an 
online learning aid.  Any attempts to copy, reproduce, or use for training is strictly prohibited.

Welcome to the WPF Tutorial

Welcome to the WPF Tutorial

Introduction to Windows Presentation Foundation

Overview

The Windows Presentation Foundation is Microsofts next generation UI framework to create applications with a rich user experience. It is part of the .NET framework 3.0 and higher.
WPF combines application UIs, 2D graphics, 3D graphics, documents and multimedia into one single framework. Its vector based rendering engine uses hardware acceleration of modern graphic cards. This makes the UI faster, scalable and resolution independent.
The followinig illustration gives you an overview of the main new features of WPF

Separation of Appearance and Behavior

WPF separates the appearance of an user interface from its behavior. The appearance is generally specified in the Extensible Application Markup Language (XAML), the behavior is implemented in a managed programming language like C# or Visual Basic. The two parts are tied together by databinding, events and commands. The separation of appearance and behavior brings the following benefits:
  • Appearance and behaviour are loosely coupled
  • Designers and developers can work on separate models.
  • Graphical design tools can work on simple XML documents instead of parsing code.

Rich composition

Controls in WPF are extremely composable. You can define almost any type of controls as content of another. Although these flexibility sounds horrible to designers, its a very powerful feature if you use it appropriate. Put an image into a button to create an image button, or put a list of videos into a combobox to choose a video file.
 
<Button>
    <StackPanel Orientation="Horizontal">
        <Image Source="speaker.png" Stretch="Uniform"/>
        <TextBlock Text="Play Sound" />
    </StackPanel>
</Button>
 
 

What's New in the .NET Framework


What's New in the .NET Framework

As of the writing of this course, version 3.5 of the .NET Framework has been released. Version 3.5 includes features that encompass all facets of Windows, Web, and network development:
  • Includes just under 10,000 classes, methods, and properties.
  • Complies with the latest Web development standards.
  • Introduces revolutionary technologies used in Windows Vista development, rich media and user experiences, workflow management, security and authorization, and complete distributed communication protocols.
The .NET Framework can also be fully extended by developers to create custom classes and types. The functionality of the .NET Framework spans the server, the workstation, and the Web. The four primary additions to the .NET Framework as of version 3.0 are:
  1. Windows Presentation Foundation (WPF)
  2. Windows Communication Foundation (WCF)
  3. Windows Workflow Foundation (WF)
  4. CardSpace

Windows Presentation Foundation (WPF)

WPF is used to develop elaborate user interfaces like those that adorn Windows Vista and managed advanced media streaming and integration. WPF is the a complete revamp of Windows Forms so that user interface, graphic, and media development is now designed around the .NET Framework.

Windows Communication Foundation (WCF)

WCF encompasses the ASP.NET Web Services and .NET remoting functionality that was contained in the .NET Framework 2.0 as well as new communication technologies.

Windows Workflow Foundation (WF)

WF is used to model complex workflow processes.

CardSpace

CardSpace is the embodiment of new security and user authorization functionality.

ASP.NET AJAX

ASP.NET AJAX was developed to improve performance in the browser by making post backs and calls between the browser and server asynchronously. ASP.NET AJAX uses new built-in types and controls and JavaScript.
Both ASP.NET and ASP.NET AJAX are heavily dependent upon the ASP.NET page event life cycle, are tightly coupled to the server, and have a tough time competing with advanced, media-rich plug-in solutions such as Adobe Flash. Additionally, it is difficult to create Web applications that offer a consistent experience across all supported browsers and platforms by using ASP.NET and AJAX. In 2006, Microsoft began developing a solution to extend into the browser and offer media experiences more robust than competing plug-in solutions.
In 2007, Microsoft introduced Silverlight. (see footnote) Silverlight is a free plug-in that encompasses a subset of functionality from the .NET Framework and WPF. In a manner similar to the JVM (see footnote), Silverlight runs in the browser as a "sandbox" - a secure zone installed into the browser that accommodates Silverlight functionality while completely protecting the host platform from any possibly adverse actions performed by Silverlight.

Silverlight Architecture

Unlike ASP.NET, the bulk of Silverlight processing occurs on the client machine thus decreasing server resource utilization and improving the Web experience on the client. The figure below shows the difference between ASP.NET processing and Silverlight processing:
When a client initially attempts to run a Silverlight application, if the Silverlight plug-in has not been installed on the client machine, it will be downloaded and installed. Upon subsequent requests to run the application, the application will instantiate on the client machine and make requests for resources from the server only when necessary. The Silverlight plug-in can be thought of as a scaled-down version of the full .NET Framework. It only contains those classes and functionality that are applicable to a Silverlight Web client and those were streamlined and optimized for use on the Web client machine.
Silverlight was designed using the same design paradigm as ASP.NET. Each page of a Silverlight application includes an associated code behind file that includes the code that handles events fired by the page. Silverlight resembles WPF in that it uses Extensible Application Markup Language (XAML) to construct the user interface (presentation layer). As Silverlight applications are composed of text-based files that include markup and code, they can be created using any text editor; however, more advanced tools and development environments such as Visual Studio or Expression Blend simplify the task significantly.

Silverlight Technologies

Version 1.0 of Silverlight used JavaScript and supported the industry-leading Windows Media Services enabling delivery of audio and video that includes 2D and vector graphics.
Version 2 includes all features of version 1.0 and:
  • support for the .NET Framework.
  • support for .NET-compliant programming languages such as C#, Visual Basic, Python, and Ruby.
  • support for database operations and language-integrated query (LINQ).
The figure below illustrates the major differences between version 1.0 and version 2:
The diagram located at ClassFiles/WhatIsSilverlight/Demos/SilverlightTechnologyMap.gif gives a broad picture of the technologies to be supported by Silverlight version 2.

Silverlight Hosting

Microsoft Silverlight functionality is completely encapsulated within the Silverlight plug-in. Web applications typically require the server hosting the Web application to meet minimum requirements. Silverlight applications simply require a Web server to be equipped as they would be for hosting HTML documents. Silverlight applications can be hosted on any Web server accessible to the target audience. The two most commonly used Web servers are Microsoft Internet Information Server (IIS) and Apache.
Executing a Silverlight application on a Web client machine is a two step process. First, the application will detect if the Silverlight plug-in is installed on the Web client machine. If the plug-in is not installed, the user will be prompted with an option to download the plug-in. If the user opts to do so, a request will be made of the Web server to download and install the plug-in. The Silverlight plug-in is embodied in a .dll executable file that is loaded into the Web client browser memory once installed. The only interaction required by the Web client when installing the Silverlight plug-in is to grant permission for the plug-in to be installed. Various Web servers, including Microsoft Internet Information Server (IIS), may require slight configuration modifications so that the Silverlight executable file will be downloaded to the Web client when requested.
Second, once the Silverlight plug-in is installed on the Web client machine, the Silverlight application itself must be downloaded. A Silverlight application may consist of many types of files. Slight configuration modifications may be necessary on the Web server, such as MIME types, so that XAML and XAP files are associated with Silverlight and downloaded correctly to the Web client machine when requested.
Once the Silverlight plug-in is installed on a Web client machine and a Silverlight application is downloaded, the Silverlight application is then hosted on the Web client machine. There are some requirements necessary for the Web client machine as discussed in the sections below, however all media players, audio and video codecs, compilers and the runtime are encapsulated in the Silverlight plug-in.

Supported Platforms

Silverlight can be installed on Windows and Macintosh machines. Silverlight applications run within the confines of a plug-in. There are many benefits to using a plug-in with the primary benefit being consistency across implementations. A plug-in application can provide a consistent result in every instance where it is supported. Other plug-in solutions, such as Adobe Flash, have become popular due to consistency across implementations. For instance, a plug-in application should deliver a consistent result regardless of whether it is displayed using Internet Explorer on Windows or Safari on a Macintosh.
Silverlight 2 is currently supported on the platforms discussed below. (see footnote)
Platforms that Support Silverlight 2
Operating SystemBrowser
  • Windows Vista
  • Windows XP SP2
  • Windows 2000
  • Windows Server 2003
  • Internet Explorer 7+
  • Firefox 1.5+
  • Google Chrome
  • Macintosh OS 10.4.8+ (Intel Based)
  • Safari
  • Firefox 1.5+

Linux

Many developers are unaware that a version of the .NET Framework exists for the Linux operating system. Linux is an open source operating system that is supported heavily in the online community. The version of the .NET Framework that supports Linux is named the Mono project and was also developed by the open source community. The developers of the Mono project keep the project close to in sync with the .NET Framework when updates are released by Microsoft and created an initial, limited version of Silverlight (called "Moonlight") that supports Linux in approximately 21 days! (see footnote) You can get up to date information on this project at http://www.mono-project.com/Moonlight .

Future Platforms

The Silverlight plug-in renders graphics and multimedia using a vector-based graphics engine. Vector graphics can easily be scaled from very small displays to very large displays of varying resolutions with virtually no loss of image quality. Silverlight on a Windows Mobile device will accommodate delivering live, streaming, high quality video to smart phones and similar devices. The goal is to enable developers to deliver rich interactive applications (RIA) to any type of device.
Microsoft has announced support for Silverlight on mobile devices with a limited initial support for Windows Mobile and the Nokia S60 models. You can learn more about this future support athttp://www.microsoft.com/silverlight/overview/mobile.aspx .

What is Silverlight? Conclusion

In this lesson of the Silverlight tutorial, you
  • Explored Microsoft Silverlight at a high level.
  • Studied some of the history leading up to the release of Silverlight.
  • Investigated the architecture of Silverlight.
  • Learned which operating systems and browsers support Silverlight 2.

What is Silverlight?


Table of Contents:


What is Silverlight?

Silverlight is a powerful cross-browser & cross-platform technology for building the next generation web experience & rich internet applications for the web. You can run Silverlight in most of all the popular browsers like Internet Explorer, Firefox, Chrome, Safari etc. Silverlight can run in various devices and operating systems like Windows, Apple Mac OS-X and Windows Phone 7. Using Silverlight you can create rich, visually stunning web applications like flash. Also you can create smooth animations using Storyboards; you can stream media over the net etc.

Silverlight web browser plug-in comes as free to install (approximately 4-5 MB in size). You can download the required plug-in from Microsoft Silverlight Site.

What are the System Requirements for installing Silverlight?

Minimum System Requirements for installing Silverlight plug-in is as follows: 
PC TypeProcessorRAMOperating System
Windows PC500 MHz or higher, x86 or x64 bit processor128 MBWindows XP SP2+
Mac Power PCPowerPC G4 800 MHz or higher128 MBMac 10.4.8 or higher
Mac Intel-basedIntel Core Duo 1.83 GHz or higher128 MBMac 10.4.8 or higher

Silverlight also supports Linux PCs. The plug-in name for Linux operating system is Moonlight and you can get the information about it in Mono Project's Moonlight site (http://www.mono-project.com/Moonlight ). 

Minimum System Requirements for installing Silverlight SDK for development is as follows: 
If you are a developer and want to start working on it, you must need the following environment to install the Silverlight tools. 
Operating System- Microsoft Windows XP Service Pack 2 or higher
Developer Tools- Visual Studio 2008 SP1 (for Silverlight 3)
- Visual Studio 2010 (for Silverlight 3 & Silverlight 4)
Designers Tools- Microsoft Expression Blend 3 (for Silverlight 3)
- Microsoft Expression Blend 4 (for Silverlight 3 & Silverlight 4)
Silverlight SDK- Silverlight 3 Tools for Visual Studio 2008 SP1
- Silverlight 4 Tools for Visual Studio 2010


How can I know whether Silverlight is installed in my PC?

If you are not sure whether Silverlight is already installed in your PC, just go to the Microsoft Silverlight Installation Page (http://www.microsoft.com/getsilverlight/get-started/install/ ) and that will tell you whether the plug-in is already installed or you need to install. 


What are the Prerequisite to create a new Silverlight Application?

Before starting with the Silverlight application development be sure you have all the necessary softwares installed in your PC. If you don’t have then follow the steps mentioned in Microsoft Silverlight Site (http://silverlight.net/getstarted/ ) to download & install the following items in your development environment: 
  • Visual Studio 2008 SP1 for Silverlight 3 application development or Visual Studio 2010 for Silverlight 3 & Silverlight 4 application development
  • Silverlight 3 Tools for Visual Studio 2008 SP1 or Silverlight 4 Tools for Visual Studio 2010
  • Expression Blend 3 for Silverlight 3 or Expression Blend 4 Preview for Silverlight 4 (optional)
  • WCF RIA Services for Silverlight (optional)
  • Silverlight 3 Toolkit or Silverlight 4 Toolkit based on your earlier version of Silverlight (optional)
Remember that, Silverlight 3 comes preinstalled with Visual Studio 2010 and hence if you are using Visual Studio 2010, you don’t need to install the Silverlight 3 Tools for it. Using Visual Studio 2010 you can develop both Silverlight 3 and Silverlight 4 applications but Visual Studio 2008 SP1 only supports Silverlight 3. 

If you have proper development environment ready for Silverlight application you can proceed to the next chapter for creating our first simple Silverlight project. I am using Visual Studio 2010 RC and Silverlight 4 RC while writing these applications. Hence, the attached samples will not open in Visual Studio 2008. 


What is XAML?

XAML stands for eXtended Application Markup Language. It is nothing but an XML file which is used to declaratively create the User Interface of the Silverlight or WPF applications. This XAML file generally rendered by the Silverlight plugin and displayed inside the browser window. When you compile your projects which includes XAML pages, those first converts into BAML (Binary Application Markup Language) and then rendered in the web browser window. Let use see a simple example of XAML here:
 

The above XAML is a typical example where I am creating a text using the TextBlock control by specifying different properties as attributes to the control for name, font-family, weight, text etc. 

What is App.xaml file?

App.xaml file is the loader of your Silverlight Application. You can declare your shared/global resources, styles, templates, different brushes inside this file which will be accessible by your application. 

A typical App.xaml file looks like:  

 

It has a code behind file too named as “App.xaml.cs”. This file is used to handle global application level events which you can use as per your need. Visual Studio creates these two files at the time of project creation. The three events inside the App.xaml.cs are: 
  • Application_Startup
  • Application_Exit
  • Application_UnhandledException.
These three events are registered in the constructor of your App.xaml.cs file. Here is the code snippet of the same:  

 

Let us do a brief discussion on each part of the code file. 

Overview of App Constructor: Inside the constructor of the App class you will find that all the three event has been registered. Also, there is a call to InitializeComponent() method. If you look around the whole class you will not find the method implementation. Strange!!! Where is the method? 

The method has been implemented inside the partial class of the App class. If you go to the definition or just press F12 on top of the method, Visual Studio will open up the actual file named “App.g.i.cs” which contains the partial implementation of the same class. There you will find the method implementation. 

What this method does: This method is responsible to load the XAML using the LoadComponent() method into the memory which can be used by your application. 

What can we do inside the App.g.i.cs file: App.g.i.cs file is auto generated by the compiler and hence if you modify something there will be overwritten by the compiler itself on next build. 

Why this file is not available inside my solution: As this is an compiler generated file, it has been placed inside the temporary directory named “obj”. If you go to the solution directory you will see the “obj” folder. Open it and browse through it’s subfolder (either debug or release) and you will see the file placed there. If you are unable to find it there, just do a rebuild of your solution and immediately it will be created there. 

Overview of Application_Startup Event: 
Application_Startup event is the root of your application. In this event you can create the instance of your initial page and set it as the RootVisual. Also, if you want to create some global objects or want to write some app initialization code, then this Application_Startup event will be the best part for you to implement it. 

Overview of Application_Exit Event: 
Similarly, you can write code to cleanup objects or do something when closing the application inside the Application_Exit event. 

Overview of Application_UnhandledException Event: 
If any exception comes while running and you didn’t handle that in the actual place, you can write some code in Application_UnhandledException to log the error details into database or show some message to the user. This will allow the application to continue running after an exception has been thrown. By default, if the app is running outside of the debugger then report the exception using the Browser DOM & the error will be visible in the status bar of Internet Explorer. 


What is MainPage.xaml file?

When you create the Silverlight project, Visual Studio IDE will automatically add a default “MainPage.xaml” file which is actually a startpage for your Silverlight application. You can modify this page as per your need or can create a new one. So, what’s there inside the file? Lets look at it:  

 
Lets walk-through each lines of the code. It contains a UserControl as root of the file which may contain all other controls inside it. The following line tells the compiler to use the specified class to use:
 

The next couple of lines beginning with xmlns tells the compiler to import some namespaces which can be used by the Silverlight XAML page. 

The following line speaks about the design time Height & Width of the Silverlight page: 
 

If you want to specify actual Height & Width of your Silverlight application, you can manually append the following line inside that: 
 

Next comes the Grid control which is used as a layout panel and that can include more other controls. Though the default XAML file uses the Grid as the layout panel, you can change it to any other panel as per your need. I will discuss about the various panel later in this tutorial. 
 

“MainPage.xaml” has also it’s code behind file like App.xaml & you can use this to write code to develop your functionalities. By default, it comes empty with a call to Initialize() method inside the Constructor of the MainPage class. The implementation of this method is also available in a different partial class of MainPage inside “MainPage.g.i.cs” like “App” class. Whenever you add some controls inside the XAML page, it will be loaded here. 

What is XAP file?

XAP (pronounced as ZAP) is the compressed output of the Silverlight Application which includes application manifest file, compiled output assembly and other resources used by your silverlight application. This uses the normal ZIP compression method to reduce the total download size. When you build your Silverlight application, it actually generates this .XAP file & puts in the output folder which the .aspx page refers as source to load the application. 

Once you build your project, it will create the XAP file (in our case: SilverlightApps.HelloSilverlight.xap) and put it into the ClientBin directory of the web project. When the page loads it will pickup from the same location as the source you specified inside the aspx/html page. 


How can I host a Silverlight Application?

When you create a Silverlight project, it asks you to create a Web Application project. This project is responsible for hosting your XAP file. Generally Silverlight application doesn’t require any server to host it to run, but if you are planning to host it in web you must need a web server for that. 
Once you publish your Web Application to host in IIS, you may need to add three MIME types in your IIS Server. This is require to host it in earlier versions of IIS. Latest version of IIS comes with that configuration by default. Followings are the list of MIME Types those you need to add in your IIS Properties: 

.xap application/x-silverlight-app 
.xaml application/xaml+xml 
.xbap application/x-ms-xbap 

Silverlight Application (XAP) generally loads inside the ASPX or HTML pages pointing to the path to load the XAP. The aspx/html page uses <object /> tag to load the Silverlight application. 

Here is the code present inside the aspx/html pages for loading the Silverlight XAP: 
 

Let us go line by line to learn the basics of it. 
  • In the first line <object> tag tells the browser to load the Silverlight plug-in.
  • Next couple of lines uses <param> tag.
    • The first param “source” has the value to the location of the .xap file.
    • Second param “onError” tells the plug-in to call the javascript method mentioned in the value, if any application error occurs.
    • The third param “background” specifies the color of the Silverlight application background.
    • The next param “minRuntimeVersion” specifies the minimum required plug-in version to load your Silverlight application.
    • If “autoUpgrade” is set as true in the next param, it will automatically upgrade the runtime.
  • The next lines are very interesting. Whatever you design there, will not be visible in the browser in normal scenarios. If the user doesn’t have Silverlight runtime installed in his PC or the Silverlight plug-in is disabled this section will visible to the user. This part is well known as “Silverlight Installation Experience panel”. By default, it shows a Silverlight image to download the runtime from Microsoft site. When the user clicks on it, this starts the installation. I will discuss about the Silverlight Experience later in depth.