programming-examples/c-sharp/Others/Using MediaElement for Audio.cs

29 lines
967 B
C#
Raw Normal View History

2019-11-15 12:59:38 +01:00
Using MediaElement for Audio
<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<MediaElement x:Name="audio"/>
<Button>A Button With Sounds
<Button.Triggers>
<EventTrigger RoutedEvent="Button.Click">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<MediaTimeline Source="click.wav" Storyboard.TargetName="audio"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
<EventTrigger RoutedEvent="Button.MouseEnter">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<MediaTimeline Source="hover.wav" Storyboard.TargetName="audio"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Button.Triggers>
</Button>
</Canvas>