locked
Issue with Data Binding a media file to MediaElement.

    Question

  • All,

    I am having an issue with Data Binding a WMV file that is stored in the Assets directory.

    Below is my Class:

        public class TrainingVideo

        {

            public string TrainingVideoName { get; set; }

     

        }

    My C# Source Code:

    var DataBox = new TrainingVideo { TrainingVideoName = "Assets/LifeControl_New.wmv" };

    TrainingMedia.DataContext = DataBox;

    Below XML Code:

    <PlayerFramework:MediaPlayer x:Name="TrainingMedia" DataContext="TrainingVideo" HorizontalAlignment="Left" Height="623" Margin="10,5,0,0" Grid.Row="1" VerticalAlignment="Top" Width="1356" Stereo3DVideoRenderMode="Stereo" Source="{Binding TrainingVideoName}"/></Grid>

    I have check the and the correct values are in the variables.

    Below is the current error message.

    Error: Converter failed to convert value of type 'String' to type 'Uri'; BindingExpression: Path='TrainingVideoName' DataItem='Windows.Foundation.IReference`1<String>'; target element is 'Microsoft.PlayerFramework.MediaPlayer' (Name='TrainingMedia'); target property is 'Source' (type 'Uri').

    When I change it to type Uri a break occurs and get a Can't “identify type or Uri.

    I am lost and could use help pointing me to the right direction. If you can please provide more than a 3 sentence comment.

    Thanks,

    Grim

    Monday, March 3, 2014 10:09 PM

All replies