Playing Movies
Almost as easy as displaying bitmaps is playing a movie. However, due to their size, video
files are almost never included in an executable and almost always are
played from a web connection. You can play a movie from my Web site in ImageExperiment by replacing the Image element with a MediaElement:
<Grid x:Name="ContentGrid" Grid.Row="1" Margin="12,0,12,0"
Background="{StaticResource PhoneAccentBrush}">
<MediaElement Source=http://www.charlespetzold.com/Media/Walrus.wmv />
</Grid>
The default value of the AutoPlay property defined by MediaElement is true, so the movie begins playing as soon as a sufficient amount has been buffered.
Non-Tiled Tile Brushes
You’ve seen examples of SolidColorBrush, LinearGradientBrush, and RadialGradientBrush. This class hierarchy is complete from Brush on down:
Object
DependencyObject (abstract)
Brush (abstract)
SolidColorBrush (sealed)
GradientBrush (abstract)
LinearGradientBrush (sealed)
RadialGradientBrush (sealed)
TileBrush (abstract)
ImageBrush (sealed)
VideoBrush (sealed)
ImplicitInputBrush (sealed)
However, the only other brush supported under Windows Phone 7 is ImageBrush, and although it derives from TileBrush,
you can’t create a tiled pattern with it. (You can in the Windows
Presentation Foundation, and perhaps someday in Silverlight.) Basically,
ImageBrush lets you set any property of type Brush to a bitmap. Here’s ImageExperiment again but with the Image element replaced with an ImageBrush set to the Background property of the content grid:
<Grid x:Name="ContentGrid" Grid.Row="1" Margin="12,0,12,0">
<Grid.Background>
<ImageBrush ImageSource="Images/BuzzAldrinOnTheMoon.png" />
</Grid.Background>
</Grid>
Like Image, TileBrush defines a Stretch property, but the default value is Fill, so the image fills the area without regard to aspect ratio.