如何从资源 WPF 在声音播放器中添加声音

How to add sound in sound player from resource WPF

如何添加这个声音image

就像我用 xaml 中的背景制作它一样。

<Controls:FlipView.Background>
                <ImageBrush ImageSource="Gamedata/MainMenuBackground.jpg"/>
            </Controls:FlipView.Background>

我已经试过了,但没用

SoundPlayer PlaySound = new SoundPlayer(@"pack://application:,,,/Gamedata/Sounds/MenuClick.wav");
        PlaySound.Load();

我不确定您到底想完成什么,但是要使用 SoundPlayer class 播放声音,您可以使用 Play() 方法。要从资源加载它,请将其添加到您的 Resources.resx 文件并使用 Properties.Resources.resourceName.

SoundPlayer PlaySound = new SoundPlayer(Properties.Resources.MenuClick);
PlaySound.Play();