我向MainWindow.xml添加了以下2种方法,但我无法触发该事件
private void Button_Click_2(object sender, RoutedEventArgs e)
{
lstContacts.Items.Clear();
cvMenuItem test = new cvMenuItem("test", Environment.GetEnvironmentVariable("USERPROFILE") + @"\Downloads\images.jpg");
test.MouseLeftButtonUp += new System.EventHandler(imClicked);
lstContacts.Items.Add(test);
}
void imClicked(object sender, EventArgs e)
{
MessageBox.Show("hello");
}我一直在犯这个错误,为什么?
无法隐式地将“System.EventHandler”类型转换为System.EventHandler MainWindow.xaml.cs 64 39 WpfApplication1
发布于 2014-01-04 19:49:49
尝尝这个
test.MouseLeftButtonUp += imClicked;
private void imClicked(object sender, MouseButtonEventArgs e)
{
MessageBox.Show("hello");
}https://stackoverflow.com/questions/20925815
复制相似问题