i am looking for a sample to play a sound like "alert.mp3" during press an
wpf alert button
i try this:
<UserControl.Resources>
<Style x:Key="Alert" BasedOn="{x:Null}" TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid>
<Rectangle Stroke="#FFFF0000" StrokeThickness="0.75" RadiusX="1.5"
RadiusY="1.5" Fill="#02FFFFFF"/>
<ContentPresenter HorizontalAlignment="{TemplateBinding
HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding
VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding
SnapsToDevicePixels}" RecognizesAccessKey="True"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsFocused" Value="True"/>
<Trigger Property="IsDefaulted" Value="True"/>
<Trigger Property="IsMouseOver" Value="True"/>
<Trigger Property="IsPressed" Value="True"/>
<!--how can i play the sound? or beginn the storyboard-->
<Trigger Property="IsEnabled" Value="False"/>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Storyboard x:Key="sirene_mp3">
<MediaTimeline BeginTime="00:00:00.0000000" Source="sirene.mp3"
Storyboard.TargetName="sirene_mp3" d:DesignTimeNaturalDuration="3" />
</Storyboard>
</UserControl.Resources>
<UserControl.Trigger>
</UserControl.Trigger>
<MediaElement x:Name="alert_mp3" Width="0" Height="0"/>
<Button Style="{DynamicResource Alert}" Width="12" Height="12" Cursor="Hand"
x:Name="button"/>