本文介绍了在Windows Phone 7的设置源MediaElement的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想设置在C#中媒体元素的来源。这是我在做什么。
I'm trying to set the source of a media element in C#. This is what I'm doing
XAML部分
<MediaElement x:Name="Sound" AutoPlay="False" /> <Button Content="Shout!" Height="123" Name="button2" Width="123" Click="shout_Click" />
C#部分
private void shout_Click(object sender, RoutedEventArgs e) { this.Sound.Source = new Uri("Sounds/fusrodah.wma", UriKind.Relative); this.Sound.Play(); }
以上不起作用。但是,如果我在XAML手动设置路径它的工作原理。我怎样才能设置在C#的MediaElement 的来源?
推荐答案你得到一个错误,或者它只是不玩?尝试添加一个斜杠,Dovahkiin:
Do you get an error, or does it just not play? Try adding a forward slash, Dovahkiin:
this.Sound.Source = new Uri("/Sounds/fusrodah.wma", UriKind.Relative);更多推荐
在Windows Phone 7的设置源MediaElement的?
发布评论