开发者

Mediaelement repeatbehavior fails when binding to xpath

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 MediaEle开发者_C百科ment 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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜