绑定到 xpath 时 Mediaelement 重复行为失败
我正在尝试使用 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# 解决方案?
I'm trying to get video's to repeat forever using MediaElement. I found the code below at http://msdn.microsoft.com/en-us/library/ms741866.aspx and it works fine.
<!-- 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>
The problem I'm having is when I try to bind the MediaTimeLine to a xml source I get the error - "Must Specify URI".
<MediaTimeline Source="{Binding XPath=MyVideos}"
Storyboard.TargetName="myMediaElement" RepeatBehavior="Forever" />
Is there a C# solution that could replace the xaml?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不使用值转换器?我知道它不完全是 WPF,即需要一些 C# 编码,但这似乎正是您想要和需要的。 WPF 教程有一个相当不错的解释,所以如果您不介意我向您推荐该页面,那么: http: //www.wpftutorial.net/ValueConverters.html
Why don't you use a value converter? I know it's not fully WPF i.e. some C# coding is required, but this seems to do exactly what you want and need. WPF Tutorials has a pretty decent explanation so if you don't mind me referring you to that page then: http://www.wpftutorial.net/ValueConverters.html