(0) exportieren Drucken
Alle erweitern

SoundPlayerAction-Klasse

Represents a light weight audio playback TriggerAction used to play .wav files.

Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)
XML-Namespaces:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

[RuntimeNamePropertyAttribute("Name")] 
public class SoundPlayerAction : TriggerAction
/** @attribute RuntimeNamePropertyAttribute("Name") */ 
public class SoundPlayerAction extends TriggerAction
RuntimeNamePropertyAttribute("Name") 
public class SoundPlayerAction extends TriggerAction

The following example shows how use the SoundPlayerAction to trigger audio playback of a .wav file using an EventTrigger on the Click and MouseEnter events.

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
  <Page.Triggers>
    <EventTrigger RoutedEvent="Button.Click" SourceName="clickButton">
      <EventTrigger.Actions>
        <SoundPlayerAction Source="media\lowbat.wav"/>
      </EventTrigger.Actions>
    </EventTrigger>
    <EventTrigger RoutedEvent="Button.MouseEnter" SourceName="hoverButton">
      <EventTrigger.Actions>
        <SoundPlayerAction Source="media\tada.wav"/>
      </EventTrigger.Actions>
    </EventTrigger>
  </Page.Triggers>

  <StackPanel Width="200">
    <Button Name="clickButton">Click to Play Sound</Button>
    <Button Name="hoverButton">Hover to Play Sound</Button>
  </StackPanel>
</Page>

System.Object
   System.Windows.Threading.DispatcherObject
     System.Windows.DependencyObject
       System.Windows.TriggerAction
        System.Windows.Controls.SoundPlayerAction

Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Microsoft .NET Framework 3.0 wird unter Windows Vista, Microsoft Windows XP SP2 und Windows Server 2003 SP1 unterstützt.

.NET Framework

Unterstützt in: 3.0
Anzeigen:
© 2014 Microsoft