xaml
<MediaElement Height="333"
HorizontalAlignment="Left"
Margin="44,83,0,0"
Name="mediaElement1"
VerticalAlignment="Top"
Width="356"
Source="/video/Windows Phone 7.wmv"/>
这是一个视频播放控件 但是有格式限制的
cs页面
public partial class MediaElment : PhoneApplicationPage
{
public MediaElment()
{
InitializeComponent();
}
//加载
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
//给它委托一个事件
mediaElement1.MediaFailed += new EventHandler<ExceptionRoutedEventArgs>(mediaElement1_MediaFailed);
}
//如果播放失败就调用这个事件
void mediaElement1_MediaFailed(object sender, ExceptionRoutedEventArgs e)
{
if (e.ErrorException!=null)
{
this.PageTitle.Text = e.ErrorException.ToString();
}
}
}