0

I'm trying to bind events to my LibraryBarItem, however when I finished like this, the MouseDown event will never be fired, can anybody tell me what happend?

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!");
}
Elderry
  • 1,902
  • 5
  • 31
  • 45
  • Have you tried setting a Background for the folderItem? If Background is Null there will be no mouse handling for this control. – LPL Jul 16 '12 at 15:27
  • Also, if a control supports the click event, it won't receive a MouseDown (for LButton) – Lee Louviere Jul 17 '12 at 00:02

1 Answers1

0

It seems that @Xaade is right, I tested and found that the LibraryItem itself did something about the click event, and when using MouseDoubleClick, it works perfectly;

Elderry
  • 1,902
  • 5
  • 31
  • 45