Media element

Topics: Prism v4 - Silverlight 4
Apr 9, 2012 at 8:00 PM

hello all
but I can not understand
Project 5.0 silvelight structured with Prism 4.1
If I place a MediaElement in the shell works properly
if you position it in a module does not work
<MediaElement Name="MediaElement1" Source="01.wmv" />
can anyone help me?

Apr 10, 2012 at 6:20 PM
Edited Apr 10, 2012 at 6:20 PM


Based on my understanding the behavior you are experiencing could be related to the fact that your module might not be locating your MediaElement's video source file.

In my opinion, as a possible approach to achieve this kind of scenarios you could drag the video file into the ClientBin folder in your web project and set the “Build Action” of the file to “None”. This way this resource file will be available for all your projects.

If so, you could define the element in you module's view for example like this:


<MediaElement Name="MediaElement1" Source="/01.wmv" />


Note the slash ("/") in the string path.

Also, another approach could be setting your file as an Embedded Resource in your module's project (Highlight the video and verify its “Build Action” is set to “Embedded Resource").

This way you could set your MediaElement using the following methods in your module's view code behind (not setting the Source property in XAML):


Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ModuleProject.01.wmv");



I hope you find this useful,

Agustin Adami

Apr 10, 2012 at 11:13 PM

thank you very much
so it works with the "/"
but I do not understand why the shell works without
thanks anyway
and I 'was very helpful

Apr 11, 2012 at 1:36 PM


I'm glad you make this work. Also I believe you could find the following MSDN article interesting, as it might be useful to better understand the use of the leading slash:


Agustin Adami