<Button Width="100" Height="50" Content="Click Me!">
<Button.Style>
<Style TargetType="{x:Type Button}">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
< here i want to play sound but how?>
</Trigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
如果有人知道,请尝试但是没有找到任何事件,请帮助我
答案 0 :(得分:0)
您可以轻松地将处理程序附加到MouseEnter和MouseLeave事件:
<Button Width="100" Height="50" Content="Click Me!"
MouseEnter="Button_MouseEnter" MouseLeave="Button_MouseLeave" />
private void Button_MouseEnter(object sender, MouseEventArgs e)
{
// start playing
}
private void Button_MouseLeave(object sender, MouseEventArgs e)
{
// stop playing
}