Gims
Gims

Reputation: 65

Binding MediaElement

We are trying to switch our application from code behind coding to MVVM pattern.

We have a MediaElement in our XAML file :

<MediaElement  Name="MyMedia" LoadedBehavior="Manual" UnloadedBehavior="Manual"  MediaEnded="MediaEnd" MediaOpened="MediaBegin" Margin="10,24,13.6,10" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Visibility="Visible" />

For the moment, with the code behind coding approach, we can access the MediaElement directly in the .xaml.cs file to call methods like MediaElement.play() or MediaElement.pause().

The problem is that we are currently blocked when we try to convert our code to MVVM, because we can't access the MediaElement in the .cs file. We are trying to bind the MediaElement itself so that we can call play or pause methods, but we haven't succeeded yet.

Any ideas ? Thank you in advance.

Upvotes: 1

Views: 4070

Answers (1)

Lainezor
Lainezor

Reputation: 500

This link describes how to control it http://msdn.microsoft.com/en-us/library/ms748248.aspx it uses an event but still calls the MediaElement.play() in the event handler.

Upvotes: 1

Related Questions