<Image Width="200"> <Image.Source> <!-- To save significant application memory, set the DecodePixelWidth or DecodePixelHeight of the BitmapImage value of the image source to the desired height and width of the rendered image. If you don't do this, the application will cache the image as though it were rendered as its normal size rather then just the size that is displayed. --> <!-- Note: In order to preserve aspect ratio, only set either DecodePixelWidth or DecodePixelHeight but not both. --> <BitmapImage DecodePixelWidth="200" UriSource="C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Water Lilies.jpg" /> </Image.Source> </Image>
image vs BitmapImage
Image is a skinnable class that wraps BitmapImage. As such BitmapImage is more lightweight, but Image has more features. So the question when to use which boils down to this: if the features of BitmapImage suffice, use that; otherwise use Image. Especially in mobile environments try to favor the use of BitmapImage.
Now what features does Image add exactly?
Image extends SkinnableComponent: this means you can assign your images a skin with a border or a dropshadow or whatever you like consistently throughout your application. It also provides a progress indicator which can be displayed while the image is loading. One more feature is the possibility to queue the loading of multiple images.