我正在尝试将事件绑定到我的LibraryBarItem,但是当我这样完成时,MouseDown事件永远不会被触发,有人能告诉我发生了什么吗?
LibraryBar folderContainer = new LibraryBar();
foreach (Image folder in states.Preparation.folders)
{
LibraryBarItem folderItem = new LibraryBarItem();
folderItem.MouseDown += clickFolder;
folderItem.Content = folder;
folderItem.Name = folder.Name;
folderContainer.Items.Add(folderItem);
}
static public void clickFolder(object sender, MouseButtonEventArgs e)
{
MessageBox.Show("Come!");
}
答案 0 :(得分:0)
似乎@Xaade是对的,我测试过并发现LibraryItem本身对click事件做了一些事情,当使用MouseDoubleClick时,它工作得很好;