O'Reilly logo

Windows® Phone 8 Unleashed by Daniel Vaughan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

GeoLocationViewModel Class

The GeoLocationViewModel.Start method instantiates either the GeolocatorProxy or a MockGeoLocator depending on the value of the viewmodel’s Boolean useMockLocator field (see Listing 17.6).

Tip

Rather than requiring the viewmodel to determine which IGeoLocator implementation it should use, Inversion of Control (IoC) could be employed to resolve the object. IoC is discussed in Chapter 24, “Unit Testing Apps.”

The Start method subscribes to the PositionChanged and StatusChanged events of the IGeoLocator, and then calls the IGeoLocator object’s Start method to begin receiving location notifications.

When the PositionChanged event is raised, the viewmodel’s GeoCoordinate property is set to the current location.

LISTING ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required