SoundPlayerAction 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示用于播放 .wav 文件的轻量音频播放 TriggerAction。
public ref class SoundPlayerAction : System::Windows::TriggerAction, IDisposable
[System.Windows.Markup.RuntimeNameProperty("Name")]
public class SoundPlayerAction : System.Windows.TriggerAction, IDisposable
public class SoundPlayerAction : System.Windows.TriggerAction, IDisposable
[<System.Windows.Markup.RuntimeNameProperty("Name")>]
type SoundPlayerAction = class
inherit TriggerAction
interface IDisposable
type SoundPlayerAction = class
inherit TriggerAction
interface IDisposable
Public Class SoundPlayerAction
Inherits TriggerAction
Implements IDisposable
- 继承
- 属性
- 实现
示例
以下示例演示如何使用 SoundPlayerAction 和 事件上的 ClickMouseEnter 来触发 .wav 文件的EventTrigger音频播放。
<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>
<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>
构造函数
SoundPlayerAction() |
初始化 SoundPlayerAction 类的新实例。 |
字段
SourceProperty |
标识 Source 依赖项属性。 |
属性
DependencyObjectType |
DependencyObjectType获取包装此实例的 CLR 类型的 。 (继承自 DependencyObject) |
Dispatcher |
获取与此 Dispatcher 关联的 DispatcherObject。 (继承自 DispatcherObject) |
IsSealed |
获取一个值,该值指示此实例当前是否为密封的(只读)。 (继承自 DependencyObject) |
Source |
获取或设置音频源位置。 |