1
  <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>

如果有人知道,我会尝试但没有找到任何活动来执行此操作,请帮助我

4

1 回答 1

0

您可以轻松地将处理程序附加到MouseEnterMouseLeave事件:

<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
}
于 2012-07-11T08:15:08.797 回答