This project is read-only.

Issue databinding StartupPosition

Topics: Windows 8 Xaml
Nov 5, 2012 at 11:30 PM


Had an issue using the player framework within a WinRT application whilst using data-binding. We attempted to bind the StartupPosition property to a property on our view-model; but it seemed to have no effect.

In the output windows we received the following error:
'Error: Converter failed to convert value of type 'Windows.Foundation.IReference`1<DateTime>' to type 'IReference`1<DateTime>'

It appears to be related to a problem that a Nullable Type is not an allowed property in XAML -

We worked around it for now by modifying the source code - we set the dependency property type to a object rather than a DateTime?



Nov 5, 2012 at 11:43 PM

Jon, yes this appears to be a limitation of Win8 Xaml at the moment unfortunately.

...irrelevant but just thought I'd mention it: Please note however that the type is TimeSpan? not DateTime? When I try I get a slightly different error:

Error: Converter failed to convert value of type 'Windows.Foundation.TimeSpan' to type 'IReference`1<Windows.Foundation.TimeSpan>'; BindingExpression: Path='Startup' DataItem='Microsoft.PlayerFramework.Samples.vm'; target element is 'Microsoft.PlayerFramework.MediaPlayer' (Name='player'); target property is 'StartupPosition' (type 'IReference`1<Windows.Foundation.TimeSpan>').

Nov 6, 2012 at 12:02 AM

Thanks for the quick response. You're spot on with the error - a mistype.

Another semi-related issue we ran into (whilst looking for an alternative workaround) was attempting to set the Position via databinding. We were trying to do this when navigating to our new View; but It didn't work because the Media element was null when setting the _Position property.

However we can set the Position property directly on the media control in the InitialiseComponent() method in code-behind.  It sets a different Position property and the value is recorded to be applied when the media element is created.  However, we could not find a Dependency Property to bind to this from our view model