The whole premise of Silverlight was that it should be .NET for the browser. That is, a well-educated .NET programmer should be able to simply start a Silverlight project and work on it without knowing anything radically new.
It is arguable that Silverlight versions 1.0 through 3.0 haven’t really made this promise come true. Now we have Silverlight 4 and perhaps it is time to take the promise seriously.
Take a few simple steps and you might be surprised at just how quickly a Silverlight project can be yours and, more to the point, how little extra you need to learn.
The beta of Silverlight 4 was announced at PDC 2009 and was immediately made available for download. Perhaps more importantly, Visual Web Designer 2010 Express and Visual Studio 2010 betas both have tools incorporated that for the first time make working with Silverlight seem as easy as working with a forms or WPF-based application. Indeed, given Silverlight uses WPF, as long as you are familiar with it then creating a web application should be almost second nature.
First, download Visual Web Designer 2010 Express. You can use the full Visual Studio 2010 if you want to, but the Express version is all you need to evaluate Silverlight.
To upgrade to Silverlight 4, download the Tools for Visual Studio.
Once you have Web Designer 2010 installed, simply start a new project using File, New Project and select either Visual Basic or C# and then select the Silverlight group. Finally select Silverlight Application.
If you focus on the Silverlight application you should recognise the basic structure of a .NET application. There is the MainPage.xaml XAML file and its code behind MainPage.xaml.cs (or vb). This is where your application code mostly resides. The App.xaml and App.xaml.cs contain the code that gets your application started.
If you would like to simply run the application, use Debug,Start Debugging or press F5, then you should see a browser open with what looks like an empty page. If you dismiss the browser, or stop debugging, you can add some details to make the page look less empty. Load the MainPage.xaml file into the designer and if you are in the least bit familiar with WPF you should recognise the XAML code that generates the page.
By default a grid layout has been use and you can now use the Toolbox to drop a button onto the page. Again you should recognise the XAML code added by the designer.
<Grid x:Name=”LayoutRoot”
Background=”White”>
<Button Content=”Button” Height=”23”
HorizontalAlignment=”Left” Margin=”146,139,0,0”
Name=”button1” VerticalAlignment=”Top” Width=”75” />
</Grid>
If you now double-click on the button you will be transferred to the code editor ready to enter instructions into the button’s click event handler. 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, RoutedEventArgs e)
{
MessageBox.Show(“Hello Silverlight World”);
}
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();
myLine.X1 = 1;
myLine.X2 = 50;
myLine.y1 = 1;
myLine.y2 = 50;
myLine.Stroke = new SolidColorBrush(Colors.Black);
LayoutRoot.Children.Add(myLine);
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.
So what more is there to say about Silverlight? As we’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 – now win the race…
Top Reasons to host your Silverlight 4 Website with HostForLife.eu
There are many reasons why so many people choose HostForLife over any other web hosting provider each year. Whether you’re beginner or an experience webmaster, HostForLife offers the perfect solution for everyone.
You’ll have highly trained, skilled professional technical support people ready, willing, and wanting to help you 24 hours a day. Your web hosting account servers are monitored from three monitoring points, with two alert points, every minute, 24 hours a day, 7 days a week, 365 days a year. The followings are the list of other added-benefits you can find when hosting with us:
1. World-class 24x7 Customer Support
Will your hosting company promptly answer questions and resolve issues - at 3 am on a Sunday? Even some providers claiming “24x7” support will not - but HostForLife will. Our outstanding uptime is backed by true 24x7 customer support. An expertly trained technician will respond to your query within one hour, round the clock. You will also get qualified answers. Other hosting companies typically have very low - level support staff during the night or weekends. HostForLife always has knowledgeable, top - level support standing by, day or night, to give you the answers you need.
2. Commitment to Outstanding Reliability
Reliability, Stability, and Performance of our servers remain out TOP priority. Even our basic service plans are equipped with standard service level agreements for 99.99% uptime. Advanced options raise the bar to 99.99%. Our state-of-the-art data centers combine servers and SAN storage with full redundancy and operational tools with proprietary service management techniques. Full backup and recovery capabilities are implemented, including redundant power supplies, cooling and connectionsto major data networks.
3. “Right-size” plans for maximum value
HostForLife offers a complete menu of services. IT professionals select only what they need - and leave behind what they don’t. The result is an optimal blend of cost and performance. We offer IT professionals more advanced features and the latest technology - ahead of other hosting companies.
4. Profitable, Stable, Debt-free Business
Financial stability is the bedrock of a hosting provider’s ability to deliver outstanding uptime, cost-effective service plans and world-class 24x7 support. HostForLife’s customers are assured of our financial integrity and stability - a stark contrast to the ups and downs they may have experienced with other providers.
5. The Best Account Management Tools
HostForLife revolutionized hosting with Plesk Control Panel, a Web-based interfaces that provides customers with 24x7 access to their server and site configuration tools. Some other hosting providers manually execute configuration requests, which can take days. Plesk completes requests in second. It is included free with each hosting account. Renowned for its comprehensive functionally - beyond other hosting control panels - and ease of use, Plesk Control Panel is available only to HostForLife’s customers.
6. 30-Day Money Back Guarantee
HostForLife 30 day money back guarantee ensures you have the ability to cancel your account anytime within your first 30 days under our full 30 day money back guarantee (less one-time account setup free). So what are you waiting for? Sign up today, risk free…
7. Simplicity with FREE 1-Click Installation
HostForLife was designed with ease of use in mind. From one click installations of your favourite website applications to our much talked about drag and drop website builder, you can rest assure your stay with us is going to be a smooth one. HostForLife offers the most extensive set of scripts on the web allowing you to build complicated websites with little or no programming knowledge at all. From blogs to forums to powerful e-commerce solutions, Super Green has something that is right for you.