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);