Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8199829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:15:06+00:00 2026-06-07T06:15:06+00:00

I am working in C# and Silverlight 5, and I am trying to display

  • 0

I am working in C# and Silverlight 5, and I am trying to display one or more audio and/or video files that have been retrieved from a database table as a byte array. I decided the best way to get those byte arrays into a usable format was to create an ObservableCollection list in my ViewModel that gets populated during the service call:

mediaFiles = new ObservableCollection<MediaElement>();
foreach (FileUpload fu in FileUploadMediaTable)
{
   using (MemoryStream ms = new MemoryStream(fu.bytes, 0, fu.bytes.Length))
   {
      MediaElement me = new MediaElement();
      me.SetSource(ms);
      mediaFiles.Add(me);
   }
}

Now, my only problem is figuring out how to add these media elements into the view. I was thinking of creating a new ItemsControl with a custom DataTemplate that defines the buttons for playback that embeds the MediaElements in a StackPanel, but how would I associate each of the buttons with that specific MediaElement?

EDIT: Of course, I guess I could just create a list of byte arrays and add a MediaElement object to the DataTemplate and pass the byte array in the source with a Bytes2ImageConverter defined. Of course, maybe I could skip that step and just bind the MediaElement’s source to a MemoryStream object created on each byte array. I am not sure of the best way to proceed (or if this stuff is even possible).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T06:15:07+00:00Added an answer on June 7, 2026 at 6:15 am

    You can create a Model class, which will contain Media source (will be bound to the MediaElement Source property) and addition data, which needed (caption, author, etc). You can use a list box for displaying all these videos. You should create an item template and use it for listbox items. This item template will contain a media element and a play/stop button, where you will bind a command. Command will be placed in your ViewModel class and you can bind a Model as command parameter. So, you can get access to medial source (Model class), which should be played. What about playing/stopping video: you can create a media element helper, which will contain an attached dependency property (for example: IsPlaying, in your model class). You will bind a true/false value for playing/stopping the video. Thats all.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working in a Silverlight 4 application. I have a datagrid that I
I'm working on a game that I'm developing in Silverlight, and I'm trying to
I have an usercontrol in silverlight that I'm trying to convert to custom control.
I have a Silverlight 5 app that gets some data from a couple Sharepoint
I am trying to get out of browser support working for my Silverlight application
I'm trying to run my Silverlight tests via a command line (eventually MSBuild) working
I'm working on a Silverlight app that has an UnhandledException handler in the App
I'm working on a Silverlight app that would allow a user to upload a
I've been trying to find a good advanced Silverlight 4 course, but can't really
I'm trying to get WCF working with Silverlight. I'm a total beginner to WCF

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.