There are a number of possible scenarios:
- bind the ItemsSource property of the MediaPlayer to a property of your ViewModel, e.g. List<RadMediaItem> MediaItems
, and add items to that property in your ViewModel. Please note that in order for the binding to work you need to set the DataContext of your page/usercontrol/window to point ot an instance of your ViewModel.
- same as above, but the property may be a list of strings that represent the sources of the media elements. In this case you will need to set the ItemTemplate property of the MediaPlayer to a DataTemplate that will create a new RadMediaItem for each string in the source and bind its source property to the business object (a string from the list of strings in your ViewModel).
- if you need a single MediaItem only, you can create that item in XAML and only bind its Source property to a string property of your ViewModel that will hold the path to the actual media file.
Let me know if the above suggestions work for you.
the Telerik team