Reputation: 75
I have MediaElement and Slider. How I can bind MediaElement.Position to Slider.Value without DispatcherTimer?
Upvotes: 3
Views: 7134
Reputation: 69
Consider PositionChanged event is called periodically by the system just approximately 4 times per second.
So you can register for PositionChanged event and update value there from code behind.
Upvotes: 0
Reputation: 19294
OK SO this COULD be that :
<Slider
x:Name="PositionSlider"
Minimum="0"
Maximum="{Binding
ElementName=mediaElement,
Path=mediaElement.NaturalDuration.TimeSpan.TotalMilliseconds}"
/>
<MediaElement
x:Name="mediaElement"
Position="{Binding Value,
ElementName=PositionSlider,
Converter={StaticResource MyMsToTimeSpanConverter}}" />
!! BUT !! Position is not a dependency property, so you cannot do any binding on it. When you say 'it doesn't work' ... SURE it doesn't, and it never will. binding requires dependency properties.
So you should do like Microsoft does for its MediaElement small demo : handle everything in code behind.
http://msdn.microsoft.com/en-us/library/ms748248.aspx
Upvotes: 1