Не работает событие left mouse button up
Код:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;
using System.Runtime.InteropServices;
namespace SilverlightApplication1
{
public partial class MainPage : UserControl
{
Button btn1 = new Button();
Button btn2 = new Button();
public MainPage()
{
InitializeComponent();
btn1.Content = "hello";
btn1.Height = 30;
btn1.Width = 70;
btn1.MouseLeftButtonDown += new MouseButtonEventHandler(btn1_MouseLeftButtonDown);
btn1.MouseEnter += new MouseEventHandler(btn1_MouseEnter);
btn1.MouseRightButtonDown += new MouseButtonEventHandler(btn1_MouseRightButtonDown);
btn1.MouseLeftButtonUp += new MouseButtonEventHandler(btn1_MouseLeftButtonUp);
rootCanvas.Children.Add(btn1);
}
void btn1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
MessageBox.Show("Left Btn UP");
}
void btn1_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
MessageBox.Show("Right Button Down");
}
void btn1_MouseEnter(object sender, MouseEventArgs e)
{
}
void btn1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
MessageBox.Show("Left Btn Down");
}
}
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;
using System.Runtime.InteropServices;
namespace SilverlightApplication1
{
public partial class MainPage : UserControl
{
Button btn1 = new Button();
Button btn2 = new Button();
public MainPage()
{
InitializeComponent();
btn1.Content = "hello";
btn1.Height = 30;
btn1.Width = 70;
btn1.MouseLeftButtonDown += new MouseButtonEventHandler(btn1_MouseLeftButtonDown);
btn1.MouseEnter += new MouseEventHandler(btn1_MouseEnter);
btn1.MouseRightButtonDown += new MouseButtonEventHandler(btn1_MouseRightButtonDown);
btn1.MouseLeftButtonUp += new MouseButtonEventHandler(btn1_MouseLeftButtonUp);
rootCanvas.Children.Add(btn1);
}
void btn1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
MessageBox.Show("Left Btn UP");
}
void btn1_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
MessageBox.Show("Right Button Down");
}
void btn1_MouseEnter(object sender, MouseEventArgs e)
{
}
void btn1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
MessageBox.Show("Left Btn Down");
}
}
У меня тоже не работают евенты для нажатия и опускания, но обычный клик работает.
Решил как-нибудь проблему?