First steps with Silverlight 4 |
Written by David Conrad | |||
Thursday, 06 January 2011 | |||
Page 2 of 2
To give the button something to do let’s just pop up a messagebox with a hello world message: private void button1_Click(object sender, Now if you run the application again you will see a button and if you click it then a messagebox pops up as requested.
This should seem all so familiar that it verges on the dull and boring but… notice that this now works in any browser that has a Silverlight plug-in – e.g. Firefox as well as IE. It is also a client side technology. The page that you are viewing in the browser happens to be an ASP .NET page but if you change the URL to end .html then you will see the same button and the same behaviour. The test website set up by the Visual Web Developer contains an ASP .NET page and a standard HTML page which can be severed by any web server. What this means is that you can integrate Silverlight, and hence .NET, with any web technology you may already be using. You can use much of what you already know about WPF and .NET in general. For example, if you want to draw a line on the page you can use: Line myLine = new Line(); This should be familiar as a use of a basic WPF drawing object, i.e. Line. The idea is you create the Line object, customise it and then add to the grid’s children after checking the XAML to discover the name generated for the grid. If you run the program above you will find that it draws a retained mode diagonal line – i.e. there is no need to buffer the drawing to make the line persist when the page is covered, the redraw is automatic. That is Silverlight graphics are substantially the same in implementation as WPF graphics even if they don't make use of DirectX. So what more is there to say about Silverlight? As I’ve hinted presumably you know it all already?! Well not quite. Silverlight is running in a browser and this makes a lot of difference. Your programs need to interact with the browser, its navigation and the user in ways that aren’t quite the same as when running a desktop application. In addition there is the not-unimportant fact that the Silverlight .NET Class framework isn’t an exact copy of the entire .NET Class framework that you are familiar with. In fact you will very quickly discover that under Silverlight there are a lot of missing and modified facilities. There is much to learn if you want to make your Silverlight application standout. This short article has got you off the starting blocks and make the transition from desktop applications to Silverlight apps. You will find lots of introductory and advanced articles on using Silverlight in the I Programmer Core section.
If you would like to be informed about new articles on I Programmer you can either follow us on Twitter, on Facebook, Digg or you can subscribe to our weekly newsletter.
<ASIN:1430224258 > <ASIN:0672330628 > <ASIN:0470524650 > <ASIN:1430229888 > <ASIN:0470534044 > <ASIN:1430225491 > |
|||
Last Updated ( Friday, 07 January 2011 ) |