[SOLVED] Visual Studio 22 WPF C# MediaElement – No Media is showing up but in Designer the media keeps playing

Issue

i have to create a trivial application. To keep it simple but pretty i wanted to put a movie (.wmv) as a background via VisualBrush within a Grid. It doenst work after all. i did some research on various issues like setting "Copy to Output Directory", "Build Action" and handling files with Resource.resx, nothing helped so far. To cut out some possible issues with some code in my application, i started a new, naked project and simply put down following code:

<MediaElement Name="bgAnimation" Source="/Resources/bganimation.wmv" LoadedBehavior="Play"/>

Doesnt matter how i handle the Source or the LoadBehaviour, MediaElement at all and whatsoever, Start with or without debugging, the MediaElement doesnt show up in the application. I also tried other files etc ..
Strangely, while in "Design" Mode in VS22, the Media is always playing, which is annoying af.
Can anybody help? Thank you in advance

1.) MediaElement doesnt show up
2.) How to disable the media playing in Desing-Mode?

Solution

I put

bgAnimation.Source = new Uri(System.IO.Directory.GetCurrentDirectory().ToString() + @"/Resources/bganimation.wmv");

in the MainWindow() and it works. -.-

Answered By – vogelnotar

Answer Checked By – Robin (BugsFixing Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *