Silverlight 4 Development Tips & Tricks

Silverlight 4 Development Tips & Tricks

I’ve been doing some fun Silverlight & Bing Maps development at the moment for ID (more to be revealed later!). Now I have really got stuck in to Silverlight development I figured I would do a blog post on a couple of things I came across and cool functionality I found.

1. Asynchronous calls and updating the UI

One important thing to remember here is that you cannot update the UI from the background thread. If you try and do this you will receive an error message – ‘Invalid cross thread access’. Let’s say you have a web service call in your Silverlight application for example which works asynchronously and falls into the completed event handler once finished. You might want to then update the UI e.g. set some label text once the web service has finished executing.

In order to update the UI you need to use the UI thread. To do this we can use the dispatcher class, here is some example code -

[code lang="csharp"]this.Dispatcher.BeginInvoke(new Action(YourMethodNameHere));[/code]

2. More Mouse events

As well as having the standard ‘Click’ events Silverlight provides much more mouse events. These events allow you to respond to mouse down and mouse up actions. There is also support for mouse move/drag actions.

I have also been working with the SharePoint Client Object Model and Silverlight – I’ll save this one for another blog post!

Here is a sneak peak of what I’m working on for Intelligent Decisioning:

Sneak Peek


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">