Simple clear advice in plain English

Hands on: Coding a Silverlight application

How to convert a desktop application to the web

This is the second part of a series showing how to convert a desktop application written in Visual Basic to a Silverlight application. Putting Silverlight to work showed how to set up a Visual Studio solution, including both a Silverlight application and a web application.

The web application provides a web service with methods that get, save and delete items in a database. The database is an image catalogue, and the web service sends and receives custom objects of the type ‘photoitem’, but the same ideas work for any database.

The next step is to code the user interface and client-side logic in Silverlight. There are two parts to this. The user interface itself is most easily designed in XAML, an XML language, while for the code you can use Visual Basic or other .Net languages. You write the code in separate files using what Microsoft calls a code-behind model, similar to that in ASP.Net.

More about XAML
XAML stands for Extensible Application Markup Language, and was created by Microsoft as a declarative language for .Net, usually expressed as XML. XAML is best known as the layout language for Windows Presentation Foundation (WPF) and Silverlight, but it has other applications. The core of XAML is small, while WPF is a large add-on vocabulary.

A different vocabulary is used for the Workflow Foundation, another Microsoft technology. Conventionally, the x namespace in an XAML document refers to core XAML, which is why an object’s attribute is ‘x:name’ and not just ‘name’.

Although XAML documents are XML, it has some unusual features. You can set properties either as attributes, or as ‘property elements’, child elements which use dot syntax to show that they belong to their parent:





Another notable feature is called attached properties. An example is that child objects in a grid layout have attributes called Grid.Row and Grid.Column, which specify their location in the grid.

XAML also supports mark-up extensions, which are expressions within braces that are evaluated at runtime. One common use is for data-binding, as seen in the example below.

Reader Comments

   

Add your comment

Please keep comments constructive and free from abuse of any kind and swearing. If you wish to link to a product or service online, please do so in such a way that makes it clear that it is not spam. If you are connected to any such product you should make that clear.

We may use your comments in the magazine. We may edit your comments for clarity or to remove unacceptable material. We will attribute your comments but not share your email address.

We request your email address and record your Internet Address (IP address) in order to block spam from our site. We will never share this information without your permission.

All comments are reviewed by the Computeractive Team before being published. Please bear with the slight delay this causes, you don't need to post more than once.

Click here to read our Privacy Policy

Click here to read our site Terms & Conditions

Related articles

According to a recent report by the World Wide Web Foundation the UK is among the best in the world at putting the web to work

Index link: making the most of the internet?

Sponsored article: Talk Talk discusses the impact of the World Wide Web Foundation report on global broadband access

Content Recommendation

Question & Answer

Q.Why is Windows Backup skipping files?

> Read the answer

Q.Why do my scanned documents display gibberish?

> Read the answer

Q.How can I convert MTS files to edit in Windows Movie...

> Read the answer

Best deals on the web

img

Samsung NP350E7C-A04UK

£349.99- Buy it now

img

Toshiba Satellite C850D-11Q (PSCC2E-00R00JEN)

£299.97- Buy it now

img

Lenovo G580 (MAANJUK)

£379.99- Buy it now

Updating your subscription status Loading

Most popular articles

No matching document

Poll

Do you have Windows 8?

Jargon Buster

Computing terms explained in plain English

CPU

Central Processing Unit. Another term for a computer processor.

Great shopping deals from Computeractive

Information currently unavailable