views:

163

answers:

1

If I have a custom class called "VideoMedia" (which contains a standard Uri for the video path) and I have a DatatTemplate that I use to create a Video Player like control.

<DataTemplate DataType="{x:Type v:VideoMedia}">
    <MyLib:VideoPlayer/>
</DataTemplate>

(The VideoPlayer class extends UserControl and simply controls the playback of a Video file)

How do I add an event handler into the VideoMedia class, so that it can contain a sort of "TimeStarted" property? I need it at runtime so I can tell if the video is running.

I am storing a IDictionart collection that I iterate over each 2 seconds to tell if the videos are playing. Is there a better way of doing it?

+1  A: 

If your VideoPlayer usercontrol built properly with a IsPlaying dependancy property in it. Just do a Binding to VideoMedia.IsPlaying to the VideoPlayer.IsPlaying and you are good to go.

<MyLib:VideoPlayer  IsPlayingDP="{Binding IsPlaying}" ... />
Jobi Joy
you mean use template binding?
Mark
Just updated the post, IsPlayingDP is your usercontrol property and IsPlaying is your Viewmodel property.
Jobi Joy
I'm getting: Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=IsPlaying; DataItem='VideoMedia' (HashCode=51593576); target element is 'VideoPlayer' (Name='UserControl'); target property is 'IsPlaying' (type 'Boolean')
Mark