Moving the current item in a ListBox

I’ve been using ListBoxes with IsSynchronizedWithCurrentItem property set to True to do a lot of master/detail views recently.  When using MVVM with Command Pattern it’s wasn’t immediately obvious to me how to manipulate which item was selected when I added/removed etc from the list.

If I’ve just created a client record and added it to my ObservableCollection of Clients in my viewModel I can use CollectionViewSource to get a hold of the view and manipulate the current item e.g.

Technorati Tags: ,

Changing DataTemplates in WPF with DataTriggers

I’ve come across a few times when I want to change the layout and contents of my screen depending on what data I have in my object. I’ve found DataTriggers really useful for this.  Based on a field being populated or not is can switch out the actual template I apply to the ContentTemplate e.g.

    <DataTemplate x:Key="clientDetails">
ContentPresenter x:Name="clientDetailsPresenter"
ContentTemplate="{StaticResource clientSummary}"
Content="{TemplateBinding Content}" />

DataTrigger Binding="{BindingClient.TFN}"Value="{x:Null}">
Value="{StaticResource clientFullDetails}" />


The other spot I find this really useful is showing different data in a list when the item is Selected.


Technorati Tags: ,,

Setting focus in WPF


Setting focus to a particular element on a screen seems like a simple and common task.  It gives the user that nice fuzzy feeling when they can just start typing in the first field of a screen without having to click into it with their mouse.  In WPF it doesn’t seem that easy to do.  For a lot of screens I was able to do this in XAML using the Focus Manager e.g.

FocusManager.FocusedElement="{Binding ElementName=firstNameBox}" 

This worked pretty well in 90% of cases until I tried using this in an application using CAL where the controls are reused.  In this case I ended up having to use codebehind to set the focus on visibility changed and use element.Focus(). Seemed to be the only way to do this so it would set the correct visible field every time.  Anyone else got a better way?


Technorati Tags: ,

Speaking at Remix 2009

BlogBling_InterfaceWeb_240x320 We’re fortunate enough to be presenting at this year’s Remix in Sydney 11th June.  We’re making an appearance in the Designer Track this year and will be showing off the new Messenger Toolkit bits.  The abstract for our talk is:

<3 the New Windows Live Messenger Web Toolkit for Social Websites

See how to add IM to a site with the Windows Live Messenger Library and UI Controls, and how to build new relationships around content with Messenger social capabilities. Also hear how top sites and marketers are using the social connections of Windows Live users to grow and build brand loyalty.

What we intend to to cover is:

  • Put a little piece together to show off the latest features of the platform itself such as custom emotions on avatars, multi-point presence, xbox integration, photo sharing etc.
  • What is messenger, why would you want to use messenger on your site?
  • Show current examples
  • Show the new controls and how they fit together
  • Skinning
  • Top Australian sites mix up, thought provoking ideas of how some of the top sites in Australia could use messenger.
  • Call to action, get started today, links + resources.


There are some great sessions including Silverlight 3, Expression 3 Sketchflow, Blend 3, Virtual Earth Silverlight Control, Surface development just to name a few. Register HERE and secure your Early Bird Ticket for $199!


Don’t forget to enter the IE8 competition: build a Web Slice, Accelerator or Visual Search Provider and you could win an XBOX.  Full details HERE.


Microsoft Mapping Road Show – 9-12 June 2009

velogo The Microsoft Mapping Road Show is back this year with sessions in Melbourne, Brisbane and Sydney.  This year’s event is broken into both customer and partner sessions. This year’s special guest is Chris Pendleton a Virtual Earth Tech Evangelist in the US.

We’ll be presenting at the partner session in Brisbane on 10th June and will attend the Sydney sessions on the 12th.  Hope to see you all there.

Register at the following:

Microsoft Partner Sessions:

Microsoft Customer Sessions:


The agenda for both sessions is similar so we’ve included the extract from the customer one below:

The Microsoft mapping team are holding an event to provide you with all the information you require to integrate Virtual Earth into your business offering. Never before has it been so easy for companies to track assets, find customers, manage a mobile sales force or to make sure customers find you before they find a competitor!

Gain real insight into how map-enabling business applications can help create customer satisfaction and an optimised organisation. If you are a technologist you’ll be amazed at just how easy it is to access and integrate Microsoft maps into your existing environment. Developers should not miss this opportunity to hear from Chris Pendleton, one of the world’s leading experts on the Microsoft mapping platform.

The agenda will consist of:

Informative sessions; you will hear from customers and partners who have utilised Microsoft maps as well as technical presentations and the latest updates from the maps team.

A masterclass from Chris Pendleton highlighting useful tips and tricks for developers, ensuring you get the most out of the Microsoft mapping platform.

A valuable opportunity to network with other customers.


Future Direction for DeepEarth

DeepEarth will become an innovation centre for controls, libraries and services for use on any Silverlight mapping platform.


Some Background

DeepEarth began as a project for likeminded developers to explore what the power of Silverlight, DeepZoom and Maps could do. Huge contributions from developers like Shaun, Rick and David created an innovative open source map control with many components. At Christmas 2008 we produced a V1 release and followed up with a V1.1, many developers have downloaded and used the control with successful results. But a few things happened in March this year which stalled the project:

  • Microsoft released Silverlight 3 preview
  • Microsoft release the Virtual Earth CTP Silverlight control
  • ESRI released a Silverlight control

None of these were unexpected but certainly these made me think about what would be best for DeepEarth and developers wanting to contribute to this space. Some lessons I have learnt over the life of the project:

  • The project must be very simple to get running on your machine, tokens, source safe files and many web projects makes this tricky.
  • For people to easily contribute a few days of their valuable time the solution needs to be easy to understand or else all effort is used in just getting to terms with the existing code.
  • People want to contribute code, more flexibility is required in giving write access (Developer Role)
  • Everyone’s time is precious and although we enjoy coding new exciting silverlight controls it often takes a back seat to other commitments.
  • Commercially it is impossible to use an unsupported open source control for production environments

New Direction

Firstly we won’t be abandoning the existing control, it still is the only open source Silverlight map control available. Rather we will be componentizing the reusable controls and code and moving these into separate generic controls with implementations for other Silverlight map controls, for example the Microsoft Virtual Earth CTP Silverlight control.

Each control will be its own project within the solution, with the ability to add implementations for any Silverlight map control developers want to use. This modular approach solves many problems:

  • Developers can pick and choose what they want to use from the project for their solution
  • It will be very easy to contribute a new control or enhancement to an existing control
  • Developers can choose which base map control suits there specific needs and still use rich common controls.
  • We can provide a Silverlight 3 branch of controls.

Secondly I’m please to announce we have a commercial partner that will be providing enterprise level testing, documentation and support around this project. More details to follow on this but essentially controls developed here will be refactored, documented, unit tests created and then published back to this project under the Microsoft Public License (Ms-PL).

Lastly I have a list of the current control and some more I’ve been working on that will make the initial base of the project.

  • Navigation Control
  • Co-ordinate Control
  • Layer Control
  • Digitizer (drawing) Control
  • Timeline Control
  • Collaboration Control
  • Mini-map Control
  • WMS Control
  • Pins, Polygons, Poly-lines
  • GML Serialization (SQL2008 integration)
  • Tile Providers
  • Tile Cache Handler

Over the next few weeks there will be some restructuring here, I’d love to hear your feedback and constructive criticisms.

Powerlaw scaling Pushpin in the Virtual Earth Silverlight control

johnWeeGo[1] I was asked on the MSDN VE forum if the new Silverlight control had pushpins and indeed clustered pushpins. The answer is that it doesn’t have the concept of a pushpin but rather a much more flexible method of attaching any UIElement to the map.


In terms of clustering this is very possible but today I’d like to start by showing Powerlaw scaling from Lutz applied to the VE control.

Powerlaw scaling applies a scale transform to the object based on the zoomlevel. It makes the object full size at street level and tiny at world level. It produces a more realistic effect as you zoom in and out where a static sized object appears to grow as you zoom out.


The interesting part of this is it allows you to show much more information on the map without pins overlapping. It will reduce the situations where you need to cluster your data.

The formula I use is:

Math.Pow(0.05*(currentZoomLevel + 1), 2) + 0.01

Adding a Pushpin

Since the control has no built in Pushpin lets make our own, it will simply be a Silverlight control called pin.xaml.


For the XAML we will have Grid with the scale transform and an Image control:

<UserControl x:Class="SoulSolutions.VESL.CustomPushPin.Pin"
    <Grid HorizontalAlignment="Center" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5">
            <ScaleTransform x:Name="PinScaleTransform" ScaleX="1" ScaleY="1" />
        <Image Width="250" Stretch="Uniform" x:Name="PinImage"></Image>

Note we gave the scale transform and the image a name so we can access these in the code behind:

using System;
using System.Windows.Media;
using Microsoft.VirtualEarth.MapControl;

namespace SoulSolutions.VESL.CustomPushPin
    public partial class Pin
        public Pin()

        private Map _map;
        public Map MapInstance {
                return _map;
                _map = value;
                _map.ViewChangeOnFrame += MapViewChangeOnFrame;

        public ImageSource ImageSource
            get { return PinImage.Source; }
            set { PinImage.Source = value; }

        void MapViewChangeOnFrame(object sender, MapEventArgs e)

        private void ApplyPowerLawScaling(double currentZoomLevel)
            double scale = Math.Pow(0.05*(currentZoomLevel + 1), 2) + 0.01;
            if (scale > 1) scale = 1;
            if (scale < 0.125) scale = 0.125;
            PinScaleTransform.ScaleX = scale;
            PinScaleTransform.ScaleY = scale;

Our class has two public properties, the MapInstance, set so we can access the map itself to get the zoomlevel and listen to the ViewChangeOnFrame event, and the ImageSource property to easily set the actual image for the pin.

When the MapInstance is set we apply the initial scaling, same on every frame of ViewChange. The ApplyPowerLawScaling simply applies the formula with some min/max thresholds.

To add the pin to the map we create a new layer and use the AddChild() methods like so:

var layer = new MapLayer();

layer.AddChild(new Pin
    ImageSource = new BitmapImage(new Uri("pin.png", UriKind.Relative)),
    MapInstance = map
}, new Location(-33.86643, 151.2062), PositionMethod.Center);

Pretty cool hey? See it in action here. Download the full source here (162KB).

Next steps

If you’re interested I can show you how to implement IDisposable to clean up events and stop an animation you may want to be running on your pins as well as extend the control to have a label and a infobox balloon. Leave me a comment if you’re interested.

Girl Geek Dinner 5 – A Success

ggd5 Thursday 30 April we held our 5th Girl Geek Dinner in Brisbane.  This event was a bit different to the previous ones as we all converged upon the Microsoft office in Brisbane to have a night of Game playing.

Tracy Whitelaw was our guest speaker for the night and I’m sure all will agree she did a great job.  She shared a bit about herself and talked about women in gaming.  40% of gamers are women!

Catherine Eibner was up from Sydney and brought some great prizes with her.  The Marcus Fenix figurine and signed Gears of War poster would be a prized possession for many games.

ggd_prize ggd_prize2

We had a range of consoles/games set up for the ladies to play:


XBox 360 with Rockband


XBox 360 with tennis


PS2 with the original Guitar Hero


Wii with Dancemat and Wii Play

The night wouldn’t have happened without the help from some key people. Many thanks to Jorke and Catherine for the use of the office, helping on the night and supplying the prizes, Tracy for her great talk, Carolyn for cooking and helping me prepare the food, Jenine for the use of her PS2 and Wii, John for helping with the GGD support vehicle, food and manning Rockband all night, and Tim for taking some photos –


Virtual Earth Wrap Up April 2009

Welcome to the monthly VE Wrap Up, did you catch what happened in March? Well April doesn’t disappoint either:

Updated 3D control

The 3D control was updated in April to bring higher performance and some added features. You can use the 3D control as a mode from the AJAX web control and from as well as program plug-ins for it in .net. New features included anisotropic filtering, custom DEM (digital elevation model), a bunch of useful events and more.

Using the 3D control Ricky has made a new release of his 3D flight simulator. With full source code this is a great example to check out.



Microsoft Virtual Earth staff join Twitter

Twitter allows us to connect with people we’re interested in using short messages. It’s fast, it’s what your doing right now, maybe it’s telling people what you’re stuck on or what you just figured out. If you’re already on Twitter the good news is the Virtual Earth staff have joined as well, follow them today:

Chris Pendleton, Evangelist US:

Johannes Kebeck, Evangelist UK/Europe: 

Jerry Skaw, Public Sector US:

(And of coarse you can also follow my VE persona: )

If you tweet about some cool site or demo, something your stuck on or just that your enjoying VE then use the hash tag #virtualearth. That way it is easy to subscribe to a feed of all the cool things going on.


April Imagery Release

Another amazing 9TB+ of imagery was released in April, Chris brought the details including the stat that is covered 1 million square kilometres of Earth. It was an international mix with Argentina, Australia, Bolivia, Brazil, Canada, Chile, China, Columbia, Greece, India, Ireland, Mexico, New Zealand, Peru, Philippines, South Africa, Thailand, Turkey, Ukraine, Venezuela and Vietnam all having big updates with more countries included as well.


These are the famous floating reed villages on Lake Titicaca in Peru.

Silverlight + Virtual Earth is everywhere

The CTP Silverlight control was released back in March, during April all sorts of great demos and sites have popped up including:

Hugh’s awesome Australian thematic demo


GPS Tracks


UK Member of Parliament expense map


Pixel Shaders in Silverlight3

Thematic overlay with VideoBrush


Webcasts galore

Fleet and Mobile Workforce Solutions

What’s New in Microsoft Virtual Earth

Building Enterprise Mashups for Greater Situational Awareness with SharePoint, Virtual Earth, & Visual Fusion

Remember you can view all the previous webcast on demand here:


New Sites

The EPA in the US launched MyEnvironment. This was released on Earth day and provides access to a tonne of data. I like the fact you can navigate using the map to anywhere in the US and the dashboard style application updates automatically.


UMapper was used by Bo Zhao to create a very effective Swine Flu visualisation. I was impressed by this specific visualisation on Virtual Earth and also by UMapper’s Flash based map creation tools.


AT&T launched their FamilyMap where for a few dollars per month you can keep an eye on exactly where your family is.


Microsoft Research released to help scientists find geospatial data.



Updated VEToolkit

Chris Pietschmann has been super busy adding MVC and JQuery support, check it out on codeplex (open source)


Birds Eye / Azure / VIEW

Chris Pendleton wrote an awesome article with sample code and demo running in Windows Azure to create full images from the Birdseye tiles available in the VE Web Service.


Photosynth Silverlight Viewer

Not strictly Virtual Earth but yet another step towards the inevitable integration between these two technologies Photosynth has completely moved to a Silverlight powered viewer.



I hope you enjoyed this summary of Virtual Earth in April, if I missed anything please leave me a comment and let me know if you’d like to see this as a regular monthly post.