The sample illustrates how to use images in your app efficiently, while giving your users a great experience. The sample covers the following scenarios:

  • How to downsample an image using DecodePixelHeight and DecodePixelWidth. This scenario shows you how to take advantage of the new DecodePixelHeight and DecodePixelWidth properties on BitmapImage to save on memory when downscaling image assets. As the scenario demonstrates, reducing the size of the image this way saves memory, and in many cases, you can reduce the size of the image without affecting the quality of the image for the user.

  • How to implement a smooth pinch and zoom experience for an image. This scenario shows how to implement a smooth zooming experience using a ViewPort control and the PinchManipulation property of the OnManipulationDelta event on the ViewPort. It shows how to zoom the image around the central point of the pinch, an action that is familiar to users from when they pinch and zoom on a map on the phone.

  • How to show progress while downloading an image. This scenario uses the DownloadProgress event of the BitmapImage object to show progress while an image is being downloaded.


    Because of the internal caching mechanism of the phone, progress is visible only the first time the scenario is run. After the image is downloaded, the image is cached on the phone, assuming that resources are available to cache the image. To see the ProgressBar in action again, you need to either supply a URI of a different image, or reset the cache by restarting the emulator or by reinstalling the app. You can also slow down the network speed while running the app in the emulator by using the Simulation Dashboard in Visual Studio Express 2012 for Windows Phone.

  • How to cancel an image download. In the preceding scenario, you cannot cancel the download of the image once it has started. This scenario uses the WebClient object to download the image and shows how to use the CancelAsync() method of WebClient to cancel an in-progress download.

Build the sample

  1. Start Visual Studio Express 2012 for Windows Phone and select File > Open > Project/Solution.

  2. Go to the directory in which you unzipped the sample. Double-click the Visual Studio Express 2012 for Windows Phone solution (.sln) file.

  3. Use Build > Rebuild Solution to build the sample.

  4. To debug the app and then run it, press F5 or use Debug > Start Debugging. To run the app without debugging, press Ctrl+F5 or use Debug > Start Without Debugging.

See also