XAML代碼:
<Button Width="35" Height="23" Margin="19,27,96,100" Opacity="0" x:Name="btn1"></Button>
cs代碼:
//手動進行注冊事件(不能使用button默認的事件,這里手動注冊的事件才會觸發鼠標的按下和抬起兩個動作事件)
btn1.AddHandler(Button.MouseDownEvent, new RoutedEventHandler(bt1_MouseDown), true);
btn1.AddHandler(Button.MouseUpEvent, new RoutedEventHandler(bt1_MouseUp), true);