Sunday, September 4, 2011

Silverlight Introduction

My previous post explained about COM objects access in Silverlight application, since many doesn't know Silverlight, i will give small introduction to silverlight in this post.

Silverlight is a Browser-plugin which provides rich internet applications !, Its a client-side web technology, If you know Applets in java, this is something very similar to it but its based on Dot Net.

Silverlight is embedded in HTML, It can access client computer's resources (which i have explained as accessing COM objects in previous post), It provides rich user-interface. It supports media and graphics.

To make your web application more interactive, attractive you need silverlight, its works on any browser and any OS.

You must have browsed many web-sites and seen a box still loading with java symbol, thats Applet, similar to that Silverlight also loads parallel to web page. Silverlight runtime should be installed on client-system just like Java-runtime.

Silverlight uses XAML (Extensible Application Mark-up Language) for designing user-interface. Its simple and very easy to learn, It looks like XML + HTML. Operations to be performed in result of the interaction by user is programmed in C#.
eg: A button is placed and designed using XAML. What operations have to be performed for the click of that button is programmed using C#.

Visual studio can be used for developing a silverlight application. Choose New project-> silverlight application.
Interface should be designed in .xaml file, you can use drag-drop option of visual studio IDE and easily design interface without typing any XAML code or you can type code yourself.
Event handlers for these interface elements should be in .cs file i.e. C# code.

When you execute, it will dynamically create an HTML page and embed this silverlight application in it, but if you want to have your own HTML file, you can embed it this way.

<object height="90%"
type="application/x-silverlight-2"
data="data:application/x-silverlight-2,"
style="width: 85%; position:relative;left:5%;top:5%" >
<param name="source" value="Bin/Debug/Weighing machine.xap"/>
<param name="onerror" value="onSilverlightError" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="5.0.60401.0" />
<param name="autoUpgrade" value="true" />
a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.60310.0"
style="text-decoration: none;">
<img
src="http://go.microsoft.com/fwlink/?LinkId=161376"
alt="Get Microsoft Silverlight"
style="border-style: none"/>
</a>
<object>


anchor tag here comes as an alternate if your application is not loaded onto web page for some problem just like alternate text for an image tag.

Any doubts, can ask in comments.
Will try my level best to clarify.




2 comments:

  1. Your article are really awesome.Actually I was in search for some good articles on Introduction and finally I got one.
    The most important is the simplicity which will be very helpful for the beginners. check this links....
    http://mindstick.com/Articles/18e56cf5-a362-427f-a8f3-7ff4ea6d0ccf/?Introduction%20to%20Silverlight

    http://blogs.msdn.com/b/tims/archive/2007/04/15/introducing-microsoft-silverlight.aspx

    http://www.c-sharpcorner.com/uploadfile/keesari_anjaiah/silverlight-introduction/

    Thanks

    ReplyDelete