Here’s a simple question that to my surprise, I can’t find the answer to: How do I play a system sound in XAML?
I have an event trigger attached to a button. The trigger displays a message, and I want it to play the Windows Notify sound. I have found several references on how to play sound files, but nothing on how to invoke a system sound.
Thanks for your help!
The
SystemSoundsclass provides some system sounds, they have aPlay()method. To use this in XAML you would either have to resort to some whacky hacks, implement lots of custom logic or use Blend Interactivity to define your own TriggerAction which can use aSystemSoundand play it.The Interactivity method:
(I do not know if
SystemSounds.Beepis the one you are looking for.)David Veeneman’s Note:
For others researching this issue, the Blend Interactivity referred to in the answer requires a reference to System.Windows.Interactivity.dll, which is found in
C:\Program Files (x86)\Microsoft SDKs\Expression\Blend\.NETFramework\v4.0\Libraries\