If you use Expression Blend you have the option to use Behaviors to help with your coding. One such behavior is the PlaySoundAction behavior. This one lets you play a sound with just XAML code.
Here is an example:
<Button Content="Button" Height="28" Canvas.Left="145" Canvas.Top="369" Width="48">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<ei:PlaySoundAction Source="beep-3.wav"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
In this example when the button is pressed a noise will play. Keep in mind the sound file needs to have a “Build Action” of “Content”, and a “Copy to Output Directory” of “Copy if newer” or “Copy always”
One Comment
Join the conversation and post a comment.



What xmlns do i need to add as i and ei?