简体   繁体   English

在 C# WPF 中发出哔哔声

[英]Making A Beep in C# WPF

Is there any ways to make a beep sound in C# WPF?有没有办法在 C# WPF 中发出哔哔声?

I've been looking for WPF beeping, but all I could find was Beeping in normal windows form.我一直在寻找 WPF 哔哔声,但我能找到的只是普通窗口形式的哔哔声。

您可以使用以下方法发出“哔”声:

SystemSounds.Beep.Play();
// Plays the sound associated with the Beep system event.
SystemSounds.Beep.Play();

This works in WPF ( http://msdn.microsoft.com/en-us/library/system.media.systemsounds.beep(v=vs.110).aspx )这适用于 WPF ( http://msdn.microsoft.com/en-us/library/system.media.systemsounds.beep(v=vs.110).aspx )

 Console.Beep(3000,200)

Here's theDocumentation这是文档

BTW, this is not just restricted to console applications.顺便说一句,这不仅限于控制台应用程序。

You can play any thing:你可以玩任何东西:

SoundPlayer snd = new SoundPlayer(filePath);
snd.Play();

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

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