Play audio through event trigger : SoundPlayerAction « Windows Presentation Foundation « C# / CSharp Tutorial






<Window x:Class="SoundAndVideo.SoundPlayerTest"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="SoundPlayerTest" Height="300" Width="300">
    <StackPanel>
        <Button>
        <Button.Content>Play Through Wrapper</Button.Content>
        <Button.Style>
          <Style>
            <Style.Triggers>
              <EventTrigger RoutedEvent="Button.Click">
                <EventTrigger.Actions>
                  <SoundPlayerAction Source="test.wav"></SoundPlayerAction>
                </EventTrigger.Actions>
              </EventTrigger>
            </Style.Triggers>
          </Style>
        </Button.Style>
      </Button>
    </StackPanel>
</Window>
WPF Play Audio Through Event Trigger








24.163.SoundPlayerAction
24.163.1.Sound Player Action demoSound Player Action demo
24.163.2.Play audio through event triggerPlay audio through event trigger