简体   繁体   English

Visual Studio 22 WPF C# MediaElement - 没有媒体显示,但在 Designer 中媒体继续播放

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

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.为了保持简单但美观,我想通过 VisualBrush 在网格中放置一部电影 (.wmv) 作为背景。 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.我对各种问题进行了一些研究,例如设置“复制到 Output 目录”、“生成操作”和使用 Resource.resx 处理文件,到目前为止没有任何帮助。 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.无论我如何处理 Source 或 LoadBehaviour、MediaElement,无论是否开始调试,MediaElement 都不会出现在应用程序中。 I also tried other files etc.. Strangely, while in "Design" Mode in VS22, the Media is always playing, which is annoying af.我还尝试了其他文件等。奇怪的是,在 VS22 的“设计”模式下,媒体总是在播放,这很烦人。 Can anybody help?有人可以帮忙吗? Thank you in advance先感谢您

1.) MediaElement doesnt show up 2.) How to disable the media playing in Desing-Mode? 1.) MediaElement 不显示 2.) 如何禁用在设计模式下播放的媒体?

I put我放

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

in the MainWindow() and it works.在 MainWindow() 中并且它有效。 -.- -.-

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM