I have an issue with sound being disabled after changing a background image.
Basically, what I have is a PanoramaItem. In that Item I have placed 1 big image as the background image (lets say a flag). On that flag I have several buttons that will change the button image on press (XAML Code created in Blend) and will also play a sound. (using Click Event Handler Sound.Play();)
All works fine, as long as the image is preloaded (. Layout-Image is in the back and buttons are on top/front.
However, I have now also added a button that enables the user to change the image to something from their own library, using the PhotoChooserTask. The problem now is that, yes the image gets replaced by the one the user selects but the buttons are not playing any sound anymore. The Button image still changes though, when pressed and released, which means the button is still active/enabled yet the sound is either disabled or the click even handler is no longer working.
Would you have an idea as to why that is? I played around with it all night last night and couldn't figure it out.
Any help is greatly appreciated :-)
EDIT:
Here is the code that I am using to load the picture:
void photoChooserTask_Completed(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK)
{
System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
bmp.SetSource(e.ChosenPhoto);
BackGroundIMG.Source = bmp;
}
}
My XAML Code for the Picture is:
<Image Name="BackGroundIMG" Source="/Assets/Test.jpg" Grid.RowSpan ="3" Grid.ColumnSpan = "3"/>
XAML Code for MediaSound is:
<MediaElement x:Name="Theme" Source="/Assets/Theme.wav" Volume="1" Autoplay="False"/>
XAML Code for the Button is:
<Button Name="Button1" Click="Button1_Click" Grid.Row="1" Grid.Column ="1"/>
Image and Button are in the same Grid. under Layout I have set the BackGroundImage to "Sent to Back" and the Button is on top of it.
C# for playing Sound:
private void Button1_Click (object sender, RoutedEventargs e)
{Theme.Play();}
So again, the sound plays fine when I start the App and just press the button but no sound will be played once I change the background image.
So my guess is, that the picture is not loaded correctly, but I am not sure how to test/change that.