WinRt媒体元素绑定C#
我有DataTemplate,其中我需要播放绑定的MediaElemnt或mp3声音,但当我点击DataTemplate中的图像时,我无法从代码中访问它WinRt媒体元素绑定C#,c#,xaml,windows-8,windows-runtime,microsoft-metro,C#,Xaml,Windows 8,Windows Runtime,Microsoft Metro,我有DataTemplate,其中我需要播放绑定的MediaElemnt或mp3声音,但当我点击DataTemplate中的图像时,我无法从代码中访问它 <Page.Resources> <DataTemplate x:Key="lol"> <Image Height="52" Width="54" Margin="282,-1,22,49" Source="ms-appx:///png/sound-icon.png" Tapped="Imag
<Page.Resources>
<DataTemplate x:Key="lol">
<Image Height="52" Width="54" Margin="282,-1,22,49" Source="ms-appx:///png/sound-icon.png" Tapped="Image_Tapped_1" />
</DataTemplate>
</Page.Resources>
有什么办法解决这个问题吗?试试这个:
import Microsoft.PlayerFramework.MediaPlayer
MediaPlayer mp = new MediaPlayer();
mp.Source = new Uri("ms-apps:///mp3/1.mp3");
mp.IsInteractive = true;
更改1.mp3的属性,如下所示:
你试过“ms”吗-appx:///mp3/1.mp3而不是“ms appx:/mp3/1.mp3”?是,但不工作!您是否已从1.mp3的属性将生成操作设置为1.mp3的内容?是的,其生成操作已包含内容。请尝试
music.Source=new Uri(“ms”)-appx:///mp3/1.mp3“”
在音乐
的加载
事件中。
import Microsoft.PlayerFramework.MediaPlayer
MediaPlayer mp = new MediaPlayer();
mp.Source = new Uri("ms-apps:///mp3/1.mp3");
mp.IsInteractive = true;