I’m writing a class library (Windows Phone 7 target) that has a public property named SoundFilePath.
In the most common scenario, the calling WP app will populate it with the relative path to the WAV file. Then the class library is expected to play it at certain events.
Think of this as a simplified tree structure for a Windows Phone solution that would use my class library from MainPage.xaml.
WPSolution_
|_References
| |_MyClassLibrary.dll
|_MainPage.xaml
|_Sounds
| |_beep.wav
Somewhere in MainPage.xaml you’d have:
var mcl = new MyClassLibrary();
mcl.SoundFilePath = "Sounds/beep.wav";
My question is how would my class library know where to look for the resource?
I tried several things including the following, to no avail:
Uri uri = new Uri(SoundFilePath , UriKind.Relative);
StreamResourceInfo sri = Application.GetResourceStream(uri); // sri was null
Answer provided by Gros Lalo. Just had to set the Build Action of the WAV to Content.