我正在尝试使用 MediaElement 让视频永远重复。我在http://msdn.microsoft.com/en-us/library/ms741866.aspx找到了下面的代码,它工作正常。
<!-- The MediaElement control plays the sound. -->
<MediaElement Name="myMediaElement" >
<MediaElement.Triggers>
<EventTrigger RoutedEvent="MediaElement.Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<!-- The MediaTimeline has a RepeatBehavior="Forever" which makes the media play
over and over indefinitely.-->
<MediaTimeline Source="C:\MyVideo1.wmv" Storyboard.TargetName="myMediaElement"
RepeatBehavior="Forever" />
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</MediaElement.Triggers>
</MediaElement>
我遇到的问题是,当我尝试将 MediaTimeLine 绑定到 xml 源时,我收到错误 - “必须指定 URI”。
<MediaTimeline Source="{Binding XPath=MyVideos}"
Storyboard.TargetName="myMediaElement" RepeatBehavior="Forever" />
是否有可以替代 xaml 的 C# 解决方案?