18
1/18 www.codeproject.com/Articles/34433/21-Important-FAQ-questions-for-WPF-and-SilverLight × highlights off Not quite what you are looking for? You may want to try: PSAM WPF Control Library WPF Tutorial : Beginning 9,210,424 members and growing! Email Password Sign in Join Lost password? Home Articles Quick Answers Discussions Zones Features Community Help! introduction to wpf Article Browse Code Stats Revisions (12) Alternatives 20 » Platforms, Frameworks & Libraries » Windows Presentation Foundation » General Licence CPOL First Posted 24 Mar 2009 Views 93,360 Downloads 1,129 Bookmarked 198 times Important FAQ questions for WPF and Silverlight By Shivprasad koirala | 9 Aug 2010 | Article C# .NET Dev XAML WPF Intermediate Silverlight Twenty one important FAQ questions for WPF and Silverlight. Part of The WPF / Silverlight Zone sponsored by See Also More like this More by this author 4.85 (78 votes) Download source code - 535 KB Video demonstration One Way, Two Way, and One Time Bindings using Silverlight Introduction Introduction What is the need for WPF when we have GDI, GDI+, and DirectX? How does hardware acceleration work with WPF? Does that mean WPF has replaced DirectX? Can we define WPF in a precise way? What is XAML? Is XAML meant only for WPF? Can you explain the overall architecture of WPF? Which are the different namespaces and classes in WPF? The different elements involved in a WPF application What are dependency properties? Are XAML files compiled or built at runtime? Can you explain how we can separate code and XAML? How can we access XAML objects in behind code? What is Silverlight? Can Silverlight run in other platforms other than Windows? Come on, even WPF runs under browser, why Silverlight? What is the relationship between Silverlight, WPF, and XAML? Can you explain the Silverlight architecture? Source code Other Silverlight FAQ Hot News: Windows 8 review: Yes, it's that bad The Code Project Insider. Free each morning. Related Articles Introduction to Attached Behaviors in WPF Introduction to WPF Introduction to WPF Templates Introduction to the WPF DataGrid WPF Introduction: Databinding +

Important FAQ questions for WPF and Silverlight - CodeProject.pdf

Embed Size (px)

Citation preview

Page 1: Important FAQ questions for WPF and Silverlight - CodeProject.pdf

1/18www.codeproject.com/Articles/34433/21-Important-FAQ-questions-for-WPF-and-SilverLight

×

highlights off

Not quite what you are looking for? You may want to try:

PSAM WPF Control LibraryWPF Tutorial : Beginning

9,210,424 members and growing! Email Password Sign in Join Lost password?

Home Articles Quick Answers Discussions Zones Features Community Help! introduction to wpf

Article Browse Code Stats Revisions (12) Alternatives 20

» Platforms, Frameworks & Libraries » Windows Presentation Foundation »

General

Licence CPOL

First Posted 24 Mar 2009

Views 93,360

Downloads 1,129

Bookmarked 198 times

Important FAQ questions for WPF andSilverlightBy Shivprasad koirala | 9 Aug 2010 | Article

C# .NET Dev XAML WPF Intermediate Silverlight

Twenty one important FAQ questions for WPF and Silverlight.

Part of The WPF / Silverlight

Zone sponsored by

See Also

More like this

More by this author

4.85 (78 votes)

Download source code - 535 KB

Video demonstration One Way, Two Way, and One Time Bindings using Silverlight

Introduction

IntroductionWhat is the need for WPF when we have GDI, GDI+, and DirectX?How does hardware acceleration work with WPF?Does that mean WPF has replaced DirectX?Can we define WPF in a precise way?What is XAML?Is XAML meant only for WPF?Can you explain the overall architecture of WPF?Which are the different namespaces and classes in WPF?The different elements involved in a WPF applicationWhat are dependency properties?Are XAML files compiled or built at runtime?Can you explain how we can separate code and XAML?How can we access XAML objects in behind code?What is Silverlight?Can Silverlight run in other platforms other than Windows?Come on, even WPF runs under browser, why Silverlight?What is the relationship between Silverlight, WPF, and XAML?Can you explain the Silverlight architecture?Source codeOther Silverlight FAQ

Hot News: Windows 8 review: Yes,it's that badThe Code Project Insider. Freeeach morning.

Related Articles

Introduction to Attached Behaviorsin WPF

Introduction to WPF

Introduction to WPF Templates

Introduction to the WPF DataGrid

WPF Introduction: Databinding +

Page 2: Important FAQ questions for WPF and Silverlight - CodeProject.pdf

2/18www.codeproject.com/Articles/34433/21-Important-FAQ-questions-for-WPF-and-SilverLight

Introduction

This article talks about 21 important FAQ from the perspective of WPF and Silverlight. Both of thesetechnologies are connected to a certain extent. This article not only explains the theory aspect of thesetechnologies, but also shows small samples for each of them.

Here’s a complete free e-book covering 400 FAQ for C#, SQL Server, WPF, WWF, WCF, and a lot more,feel free to download it and enjoy: http://www.questpond.com/SampleDotNetInterviewQuestionBook.zip.

What is the need for WPF when we have GDI, GDI+, and DirectX?

First let’s try to understand how Microsoft display technologies have evolved:

User32: This provides the Windows look and feel for buttons and textboxes and other UIelements. User32 lacked drawing capabilities.GDI (Graphics Device Interface): Microsoft introduced GDI to provide drawing capabilities. GDInot only provides drawing capabilities but also a high level of abstraction on hardware display. Inother words, it encapsulates all complexities of hardware in the GDI API.GDI+: GDI+ was introduced which basically extends GDI and provides extra functionalities like JPGand PNG support, gradient shading, and anti-aliasing. The biggest issue with the GDI API was it didnot use hardware acceleration and did not have animation and 3D support.

Note: Hardware acceleration is a process in which we use hardware to perform some functions

Styles + IValueConverter

Introduction to Composite WPF(CAL, Prism): Part 1

Introduction to Composite WPF(CAL, Prism): Part 2

Introduction to WPF Data Binding

Introduction to D3DImage

An Introduction to Silverlight

Introduction to wxWidgets - 2.

RavenDB - An Introduction

Introduction to Anthem.NET

Introduction to .NET

Introduction to NLog

Introduction to wxWidgets

WCF by Example - Introduction

SilverLight Introduction

XLINQ Introduction Part 3 Of 3

Introduction to WF (Part01)

LINQ Introduction Part 1 Of 3

Page 3: Important FAQ questions for WPF and Silverlight - CodeProject.pdf

3/18www.codeproject.com/Articles/34433/21-Important-FAQ-questions-for-WPF-and-SilverLight

rather than performing those functions using software running in the CPU.

DirectX: The biggest issues with GDI and its extension GDI+ are hardware acceleration andanimation support. This came as a big disadvantage for game developers. To answer and servegame developers, Microsoft developed DirectX. DirectX exploited hardware acceleration, hadsupport for 3D, full color graphics, media streaming facility, and lots more. This API did not maturein the gaming industry.WPF: Microsoft had 3 to 4 different APIs for display technologies, so why one more? DirectX hadthis excellent feature of using hardware acceleration. Microsoft wanted to develop UI elements liketextboxes, buttons, grids, etc., using the DirectX technology by which they could exploit thehardware acceleration feature. As WPF stands on top of DirectX, you can not only build simple UIelements but also go one step further and develop special UI elements like Grid, FlowDocument,and Ellipse. Oh yes, you can go one step further and build animations. WPF is not meant for

game development. DirectX still will lead in that scenario. In case you are looking for lightanimation (not game programming), WPF will be a good choice. You can also express WPF usingXML which is also called as XAML. In other words, WPF is a wrapper built over DirectX. Let’s nowdefine WPF.

WPF is a collection of classes that simplifies building dynamic user interfaces. Those classesinclude a new set of controls, some of which mimic old UI elements (such as Label, TextBox,Button), and some that are new (such as Grid, FlowDocument, and Ellipse).

How does hardware acceleration work with WPF?

Hardware acceleration is a process in which we use hardware to perform some functions rather thanperforming those functions using software running in the CPU.

WPF exploits hardware acceleration in a two tier manner.

The WPF API first detects the level of hardware acceleration using parameters like RAM of video card,per pixel value, etc. Depending on that, it uses a Tier 0, Tier 1, or Tier 2 rendering mode.

Tier 0: If the video card does not support hardware acceleration, then WPF uses the Tier 0rendering mode. In other words, it uses software acceleration. This corresponds to the working ofDirectX versions less than 7.0.Tier 1: If the video card supports partial hardware acceleration, then WPF uses the Tier 1rendering mode. This corresponds to working of DirectX versions between 7.0 and 9.0.Tier 2: If the video card supports hardware acceleration, then WPF uses the Tier 2 renderingmode. This corresponds to working of DirectX versions equal or greater than 9.0.

Does that mean WPF has replaced DirectX?

Page 4: Important FAQ questions for WPF and Silverlight - CodeProject.pdf

4/18www.codeproject.com/Articles/34433/21-Important-FAQ-questions-for-WPF-and-SilverLight

No, WPF does not replace DirectX. DirectX will still be needed to make cutting edge games. The videoperformance of DirectX is still many times higher than the WPF API. So when it comes to gamedevelopment, the preference will always be DirectX and not WPF. WPF is not an optimum solution tomake games. Oh yes, you can make a tic tac toe game with it but not high action animation games.

One point to remember: WPF is a replacement for Windows Forms and not DirectX.

Can we define WPF in a precise way?

Windows Presentation Framework is the new presentation API. WPF is a two and three dimensionalgraphics engine. It has the following capabilities:

Has all equivalent common user controls like buttons, check boxes, sliders, etc.Fixed and flow format documents.Has all of the capabilities of HTML and Flash.2D and 3D vector graphics.Animation.Multimedia.Data binding.

What is XAML?

XAML (pronounced as Zammel) is a declarative XML-based language by which you can define objectsand properties in XML. A XAML document is loaded by a XAML parser. The XAML parser instantiatesobjects and sets their properties. XAML describes objects, properties, and the relations between them.Using XAML, you can create any kind of objects, graphical or non-graphical. WPF parses the XAMLdocument and instantiates the objects and creates the relations defined by the XAML. So XAML is anXML document which defines objects and properties and WPF loads this document in actual memory.

So is XAML meant only for WPF?

No, XAML is not meant only for WPF. XAML is an XML-based language and it has several variants.

WPF XAML is used to describe WPF content, such as WPF objects, controls, and documents. InWPF XAML, we also have XPS XAML which defines an XML representation of electronic documents.Silverlight XAML is a subset of WPF XAML meant for Silverlight applications. Silverlight is a cross-platform browser plug-in which helps us create rich web content with two-dimensional graphics,animation, and audio and video.WWF XAML helps us describe Windows Workflow Foundation content. The WWF engine then usesthis XAML and invokes the workflow accordingly.

Can you explain the overall architecture of WPF?

The above figure shows the overall architecture of WPF. It has three major sections: presentation core,presentation framework, and Milcore. In the same diagram, we can see how other sections like DirectXand Operating System interact with the system. So let’s go section by section to understand howeverything works.

User32: It decides what goes where on the screen.DirectX: As said previously, WPF uses DirectX internally. DirectX talks with drivers and rendersthe content.Milcore: Mil stands for media integration library. This section is unmanaged code because it acts

Page 5: Important FAQ questions for WPF and Silverlight - CodeProject.pdf

5/18www.codeproject.com/Articles/34433/21-Important-FAQ-questions-for-WPF-and-SilverLight

like a bridge between the WPF managed and the DirectX / User32 unmanaged API.Presentation core: This is a low level API exposed by WPF providing features for 2D, 3D,geometry, etc.Presentation framework: This section has high level features like application controls, layouts,content, etc., which helps you build up your application.

Which are the different namespaces and classes in WPF?

There are ten important namespaces / classes in WPF.

System.Threading.DispatcherObject

All WPF objects derive from DispatcherObject. WPF works on an STA model, i.e., Single Threading

Apartment model. The main duty of this object is to handle concurrency and threading. When messageslike mouse clicks, button clicks, etc., are initiated, they are sent to the DispatcherObject which

verifies whether code is running on the correct thread. In the coming sections, we will look in detail howWPF threading works.

System.Windows.DependencyObject

When WPF was designed, a property based architecture was considered. In other words, rather thanusing methods, functions, and events, object behavior will interact using properties. For now, we willonly restrict ourselves to this definition. In the coming sections, we have dedicated questions for this.

System.Windows.Media.Visual

The Visual class is a drawing object which abstracts drawing instructions, how drawing should be done

like clipping, opacity, and other functionalities. The Visual class also acts like a bridge between the

unmanaged MilCore.dll and the WPF managed classes. When a class is derived from Visual, it can be

displayed on windows. If you want to create your own customized user interface, then you can programusing Visual objects.

Page 6: Important FAQ questions for WPF and Silverlight - CodeProject.pdf

6/18www.codeproject.com/Articles/34433/21-Important-FAQ-questions-for-WPF-and-SilverLight

System.Windows.UIElement

UIElement handles three important aspects: layout, input, and events.

System.Windows.FrameworkElement

FrameWorkElement uses the foundation set by UIElement. It adds key properties like

HorizontalAlignment, VerticalAlignment, margins, etc.

System.Windows.Shapes.Shape

This class helps us create basic shapes such as rectangle, polygon, ellipse, line, and path.

System.Windows.Controls.Control

This class has controls like TextBox, Button, ListBox, etc. It adds some extra properties like font,

foreground and background colors.

System.Windows.Controls.ContentControl

It holds a single piece of content. This can start from a simple label and go down to a unit level of stringin a layout panel using shapes.

System.Windows.Controls.ItemsControl

This is the base class for all controls that show a collection of items, such as the ListBox and

TreeView.

System.Windows.Controls.Panel

This class is used for all layout containers—elements that can contain one or more children and arrangethem as per specific layout rules. These containers are the foundation of the WPF layout system, andusing them is the key to arranging your content in the most attractive and flexible way possible.

The different elements involved in WPF application

In order to understand the different elements of WPF, we will do a small ‘hello world’ sample and in thatprocess, we will understand the different elements of WPF.

Note: For this sample, we have VS 2008 Express edition.

Start VS 2008 Express and from Templates, select WPF Application as show in the figure below.

Page 7: Important FAQ questions for WPF and Silverlight - CodeProject.pdf

7/18www.codeproject.com/Articles/34433/21-Important-FAQ-questions-for-WPF-and-SilverLight

Once we have created the WPF Application project, you will see two file types: the XAML file and thebehind code, i.e., XAML.cs. XAML files are nothing but XML files which have all the elements needed todisplay the window's UI. Every XAML element maps to some class. For instance, the Window element

maps to the WpfApplication1.Window1 class, Button elements in the XAML file map to a

System.Windows.Control.Button class, and the Grid XAML elements map to

System.Windows.Control.Grid.

App.XAML and App.XAML.CS are the entry point files. If we you look at the code for App.XAML.CS, youwill see a reference to the XAML file which needs to be loaded. The first code which runs in theapplication is the void main() method from App.XAML.CS which in turn loads the Window1.XAML file

for rendering.

Page 8: Important FAQ questions for WPF and Silverlight - CodeProject.pdf

8/18www.codeproject.com/Articles/34433/21-Important-FAQ-questions-for-WPF-and-SilverLight

We can now connect the behind code method and functions to the events in the XAML file elements.

You can see from the above code snippet how the Button element has the Click event linked to the

MyButton_Click function. MyButton_Click is the method which is in the XAML.CS behind code. So

now if you run the code, you can see the button and if you click on it, you can see the message box.

What are dependency properties?

Dependency properties belong to one class but can be used in another. Consider the code snippetbelow:

Page 9: Important FAQ questions for WPF and Silverlight - CodeProject.pdf

9/18www.codeproject.com/Articles/34433/21-Important-FAQ-questions-for-WPF-and-SilverLight

Collapse | Copy Code

<Rectangle Height="72" Width="131" Canvas.Left="74" Canvas.Top="77" />

Height and Width are regular properties of the Rectangle. But Canvas.Top and Canvas.Left are

dependency properties as they belong to the Canvas class. It is used by the Rectangle to specify its

position within Canvas.

Are XAML files compiled or built at runtime?

XAML files are usually compiled rather than parsed at runtime. But they also support parsing duringruntime. When we build a XAML based project, you will see it creates a g.cs extension in the obi\Debugfolder. Therefore, for every XAML file, you will find a g.cs file. For instance, a Shiv.XAML will have aShiv.g.cs file in the obi\Debug folder. In short, at runtime, you actually do not see the XAML file. But ifyou want to do runtime parsing of a XAML file, it also allows that to be done.

Can you explain how we can separate code and XAML?

This is one of the most important features of WPF, separating the XAML from the code to be handled.So designers can independently work on the presentation of the application and developers can actuallywrite the code logic independent of how the presentation is.

Figure 16.1: XAML and behind code in action

Above is a code snippet which shows a XAML file and the code completely detached from the XAMLpresentation. In order to associate a class with a XAML file, you need to specify the x:Class attribute.

Any event specified on the XAML object can be connected by defining a method with sender and eventvalues. You can see from the above code snippet that we have linked MyClickEvent to an event in

the behind code.

Note: You can find a simple sample in the WindowsSimpleXAML folder. Feel free to experiment with thecode… experimenting will teach you more than reading something theoretical.

How can we access XAML objects in behind code?

To access XAML objects in behind code, you just need to define them with the same name as given inthe XAML document. For instance, in the below code snippet, we have named the object as objtextand the object is defined with the same name in the behind code.

Page 10: Important FAQ questions for WPF and Silverlight - CodeProject.pdf

10/18www.codeproject.com/Articles/34433/21-Important-FAQ-questions-for-WPF-and-SilverLight

Figure 16.2: Accessing a XAML object

Note: You can get the source code from the WindowsAccessXAML folder.

What is Silverlight?

Silverlight is a web browser plug-in by which we can enable animations, graphics, and audio/video. Youcan compare Silverlight with Flash. We can view animations with Flash and it’s installed as a plug-in inthe browser.

Can Silverlight run in other platforms other than Windows?

Yes, animations made in Silverlight can run in other platforms other than Windows. In whatever platformyou want to run, you just need the Silverlight plug-in.

Come on, even WPF runs under browser why Silverlight?

Yes, there is something called as a WPF browser application which can run WPF in the browser. For aWPF browser application, you need the .NET Framework to be installed in the client location while forSilverlight, you need only the plug-in. So in other words, WPF browser applications are OS dependentwhile Silverlight is not. A Silverlight plug-in can run in OSs other than Windows while we all know the.NET Framework only runs in Windows.

What is the relationship between Silverlight, WPF, and XAML?

As explained previously, XAML is an XML file which defines UI elements. This XML file can be read by theWPF framework or Silverlight framework for rendering. Microsoft first developed WPF and they usedXAML files to describe UI elements to the WPF framework. Microsoft then extended WPF and madeWPF/e which helped to render the UI in the browser. WPF/e was the code name for Silverlight. LaterMicrosoft launched Silverlight officially. So the XAML just defines the XML structure to represent UIelements. Both the frameworks, i.e., WPF and Silverlight, then read the UI elements and render the UIelements in the respective platform.

Can you explain the Silverlight architecture?

Before we talk about Silverlight architecture, let’s discuss what Silverlight is really made of technically.Silverlight has borrowed a lot of things from existing Microsoft technologies. We can think of theSilverlight plug-in as a combination of some technologies from the core .NET Framework, vectoranimations, media, and JavaScript.

Page 11: Important FAQ questions for WPF and Silverlight - CodeProject.pdf

11/18www.codeproject.com/Articles/34433/21-Important-FAQ-questions-for-WPF-and-SilverLight

So we can visualize the Silverlight architecture as a combination of some functionalities from the core.NET framework, AJAX, and some functionalities like animation, media, etc., provided by the coreSilverlight framework. We can think of the Silverlight architecture as a combination of four importantblocks:

Some .NET Framework components: Silverlight uses some components from the .NET Framework.One of the main components is WPF. Many UI components (checkbox, button, textbox, etc.),XAML parsing, etc., are taken from the core WPF system. It also has taken components like WCFto simplify data access. It has CLR for memory management, safety checking, and garbagecollection. The base class libraries of .NET are used for string manipulation, algorithms,expressions, collections, and globalization.Presentation core: The core presentation framework has functionalities to display vector 2Danimations, images, media, DRM, and handles input like mouse and keyboard.Other technologies: Silverlight interacts with other technologies like AJAX and JavaScript. So italso borrows some functionalities from these technologies.Hosting: Silverlight animations finally run under the browser environment. So it has the hostingfunctionality which helps to host the application in the browser, expose a DOM by which JavaScriptcan manipulate the Silverlight components, and it also has an installer functionality which helpsinstall the Silverlight application and plug-in in the browser environment. One of the things whichyou can notice from the architecture diagram is that the presentation core reads from the XAMLfile for rendering. XAML is a component which is part of the .NET Framework and the rendering partis done by the presentation core.

Page 12: Important FAQ questions for WPF and Silverlight - CodeProject.pdf

12/18www.codeproject.com/Articles/34433/21-Important-FAQ-questions-for-WPF-and-SilverLight

The application is a typical HTML which runs under the browser. There are markups which instantiate theSilverlight plug-in. Now when the user interacts with the Silverlight application, it sends an event to theJavaScript system or the .NET system. This depends on which programming language you are using. Theprogram code which is either in JavaScript or .NET can make calls to the Silverlight runtime and achievethe necessary functionalities. XAML will be read and parsed by the Silverlight runtime and then renderedin the browser.

What are the various steps to make a simple Silverlight application?

This sample we are making using VS 2008 Web Express edition and .NET 3.5. It’s a six step procedure torun our first Silverlight application. So let’s go through it step by step.

Step 1: The first thing we need to do is install the Silverlight SDK kit fromhttp://www.microsoft.com/downloads/details.aspx?familyid=FB7900DB-4380-4B0F-BB95-0BAEC714EE17&displaylang=en.Step 2: Once you install the Silverlight SDK, you should be able to use the Silverlight template. Sowhen you go to create a new project, you will see a ‘SilverLight Application’ template as shown inthe below figure.

Step 3: Once you click OK, you will see a dialog box as shown below, which has three options:

Page 13: Important FAQ questions for WPF and Silverlight - CodeProject.pdf

13/18www.codeproject.com/Articles/34433/21-Important-FAQ-questions-for-WPF-and-SilverLight

Add an ASP.NET web project to the solution to host Silverlight: This option is the defaultoption, and it will create a new Web Application project that is configured to host and runyour Silverlight application. If you are creating a new Silverlight application, then this is theoption to go.Automatically generate a test page to host Silverlight at build time: This option willcreate a new page at runtime every time you try to debug and test your application. If youwant to only concentrate on your Silverlight application, then this option is worth looking at.Link this Silverlight control into an existing website: If you have an existing Silverlightapplication, then this option helps to link the Silverlight application with the existing webapplication project. You will not see this option enabled in new projects, you need to havean existing web application.

For this example, we have selected the first option. Once you click OK, you should see the full IDEenvironment for Silverlight.

So let’s run through some basic points regarding the IDE view that we see. You will see there aretwo projects: your web application and the Silverlight application. In the Silverlight application, wehave two XAML files: App.XAML and Page.XAML. App.XAML has the global level information.

Step 4: Now for simplicity's sake, we just use the TextBlock tag to display a text. You can see

that as we type in Page.XAML, it is displayed in the viewer.

Page 14: Important FAQ questions for WPF and Silverlight - CodeProject.pdf

14/18www.codeproject.com/Articles/34433/21-Important-FAQ-questions-for-WPF-and-SilverLight

Step 5: Now we need to consume the Silverlight application in an ASPX page. So in the HTML /ASPX page, we need to first refer to the Silverlight namespace using the Register attribute.

Collapse | Copy Code

<%@Register Assembly="System.Web.Silverlight" Namespace="System.Web.UI.SilverlightControls" TagPrefix="asp" %>

We also need to refer to the ScriptManager from the Silverlight name space. The

ScriptManager control is a functionality from AJAX. The main purpose of this control is to

manage the download and referencing of JavaScript libraries.

Collapse | Copy Code

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>

Finally, we need to refer to the Silverlight application. You can see that in the source we havereferred to the XAP file. The XAP file is nothing but a compiled Silverlight application which iscompressed and zipped. It basically has all the files that are needed for the application in acompressed format. If you rename the file to a ZIP extension, you can open it using WinZIP.

Collapse | Copy Code

<asp:Silverlight ID="Xaml1" runat="server"

Source="~/ClientBin/MyFirstSilverLightApplication.xap" MinimumVersion="2.0.31005.0" Width="100%" Height="100%" />

So your final ASPX / HTML code consuming the Silverlight application looks something as shownbelow:

Collapse | Copy Code

<%@ Page Language="C#" AutoEventWireup="true" %><%@ Register Assembly="System.Web.Silverlight" Namespace="System.Web.UI.SilverlightControls"

TagPrefix="asp" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" style="height:100%;">

<head runat="server"><title>MyFirstSilverLightApplication</title>

</head><body style="height:100%;margin:0;">

<form id="form1" runat="server" style="height:100%;"><asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager><div style="height:100%;">

<asp:Silverlight ID="Xaml1" runat="server" Source="~/ClientBin/MyFirstSilverLightApplication.xap"

MinimumVersion="2.0.31005.0" Width="100%" Height="100%" /></div>

</form></body>

</html>

Step 6: So finally set the web application as Start up and also set this page as Start up and runit. You should be pleased to see your first Silver light application running.

Page 15: Important FAQ questions for WPF and Silverlight - CodeProject.pdf

15/18www.codeproject.com/Articles/34433/21-Important-FAQ-questions-for-WPF-and-SilverLight

Article Top

Sign Up to vote Poor Excellent Vote

Search this forum Go

Source code

You can download the source code here.

Other Silverlight FAQ

LINQ FAQ Part 1: http://www.codeproject.com/KB/linq/LINQNewbie.aspxSilverlight FAQ Part 2: SilverLight FAQ's - Part2Silverlight FAQ Part 3: SilverLight FAQ's - Part3One-Many and One-One relationships using LINQ to SQL: One-Many and One-One relationshipusing LINQ to SQL

License

This article, along with any associated source code and files, is licensed under The Code Project OpenLicense (CPOL)

About the Author

Shivprasad koirala

Architecthttp://www.questpond.com

India

Member

I am a Microsoft MVP for ASP/ASP.NET and currently a CEO of a small E-learning company in India. We are very much active in making training videos, writing books and corporate trainings. Do visit my site for .NET, C# , design pattern , WCF , Silverlight , LINQ , ASP.NET , ADO.NET , Sharepoint , UML , SQL Server training and Interview questions and answers

Comments and Discussions

You must Sign In to use this message board.

Profile popups Noise Medium Layout Expand Posts & Replies Per page 25 Update

Refresh First Prev Next

Madhan Mohan Reddy 23:28 15 Jul '12

Really helpful information... thank you for sharing

Sign In · View Thread · Permalink

Vinod Satapara 19:32 27 Feb '12

100/100

Sign In · View Thread · Permalink

My vote of 5

My vote of 5

Page 16: Important FAQ questions for WPF and Silverlight - CodeProject.pdf

16/18www.codeproject.com/Articles/34433/21-Important-FAQ-questions-for-WPF-and-SilverLight

Member 8113189 1:25 26 Jul '11

y well written and informative

Sign In · View Thread · Permalink

aydinsahin 11:13 29 Oct '10

good article

Sign In · View Thread · Permalink

Ganeshpandi 11:04 29 Oct '10

Very good article

Sign In · View Thread · Permalink

AmolPandurangBorkar 23:54 15 Sep '10

Thanks for the nice article

Sign In · View Thread · Permalink

koolprasad200320:44 3 Sep '10

Good article... i have a problem..can we use silvelight in windows based application...

thanks in advanced...

Rating always..... WELCOME Be a good listener...Because Opprtunity Knock softly...Use http://www.google.com/transliterate/ for translator

Sign In · View Thread · Permalink

Member 4178170 23:48 26 May '10

Nice article

Sign In · View Thread · Permalink

akjoshi2:40 24 Mar '10

Hi, Really good article; Nicely explaind the fundamentals of WPF. I am not sure but the example you showed for dependency property looks a bit sonfusing to me; Isn'tthat more relevant to Attached proeprties rather then just dependency property?

Sign In · View Thread · Permalink

Arfan Baig 21:19 18 Mar '10

Great article!Really helpful.

Sign In · View Thread · Permalink 5.00/5 (1 vote)

gaoyuegl 21:51 12 Sep '09

Very Nicehelps a lot!!!

Sign In · View Thread · Permalink

Sathishkumar_P 2:05 24 Aug '09

Very helpful and really nice article Shiv

Sign In · View Thread · Permalink

Cybernate8:40 2 Jul '09

Very well written and informative

My vote of 5

My vote of 5

My vote of 5

can we use silverlight in windows development application?

Nice article

Great Article but is the example of dependency propertyright?

Simply Superb!

Very Nice

Really Nice

Excellent

Page 17: Important FAQ questions for WPF and Silverlight - CodeProject.pdf

17/18www.codeproject.com/Articles/34433/21-Important-FAQ-questions-for-WPF-and-SilverLight

Well structured article.Thanks for the great work.

Regards,Cybernate

Sign In · View Thread · Permalink

TheArchitectualizer 2:35 30 Jun '09

Hmm, WPF and Silverlight are both sutiable platforms for game design and development. Bill Resse createdSilverSprite, a port of XNA to Silverlight; for 2D Sprite based games. WPF can leverage HSLS, DirectX,OpenGL, CUDA, PhysicsX, etc. High level 3D abstractions can be defined in XAML and lower levelprocessing can be routed to lower level API's. Designers can still design in 3D and Developers canabstract the lower level stuff. Silverlight 3 will bring Hardware accelaration: PixelShaders, HLSL, etc.However, it is sandboxed and can not be extended. Silverlight 2 has no hardware acceleration. http://silversprite.codeplex.com/Thread/List.aspx[^] ~TheArch

Sign In · View Thread · Permalink

prasad02 19:50 1 Jun '09

Nice!

Thanks and Regards,prasad

Sign In · View Thread · Permalink

o3yoon 19:02 10 Apr '09

first I want to thank you for this great article, and last I want to help me to found discription aboutnamespaces used in WPF? and thank you again.

Sign In · View Thread · Permalink 1.00/5 (1 vote)

vikas amin 9:39 7 Apr '09

Hi shivprasad good pictorial representation

Vikas AminMy Article's on CPmodified on Thursday, July 24, 2008 5:33 PM

Sign In · View Thread · Permalink

wasimsharp 19:02 30 Mar '09

Coool really good for newbie

WANTED wasim khan(Killed 50 Innocent Buggs, Distroyed 200 Exception, make 5 Project Hostage) anyCompnay Hire him will pay 30,000. Best place where u can get him is Sorcim Technologies Murre RoadRWP

Sign In · View Thread · Permalink

kamii47 4:06 25 Mar '09

Very nicely Explained koirala.

Kamran ShahidSr. Software Engineer(MCP, MCAD.net, MCSD.net, MCTS, MCPD.net[web])Netprosys Inc.www.netprosys.com

Nice format! However...

Nice!

What is WPF namespace?

good pictorial representation

Nice Stuff

Very nicely Explained koirala

Page 18: Important FAQ questions for WPF and Silverlight - CodeProject.pdf

18/18www.codeproject.com/Articles/34433/21-Important-FAQ-questions-for-WPF-and-SilverLight

Permalink | A dvertise | P rivacy | Mobile

Web01 | 2 .5 .120820.2 | Las t Updated 10 A ug 2010

A rtic le C opyright 2009 by Shivprasad koirala

Everything else C opyright © C odeP rojec t, 1999-2012

Terms of Use

Sign In · View Thread · Permalink

dishatera 4:32 24 Mar '09

Its rare to see such articles.

Sign In · View Thread · Permalink 5.00/5 (1 vote)

Last Visit: 23:34 21 Aug '12 Last Update: 16:32 24 Aug '12 1

General News Suggestion Question Bug Answer Joke Rant Admin

Layout: fixed | fluid

Very Very Nice