I understand why this is happening. The bounding box of a parent TreeViewItem includes its children's bounding boxes, so when I am moused over a TreeViewItem, all its parents in the tree are also moused over. Is there something besides IsMouseOver I should be using?
views:
733answers:
3
A:
That sounds like the right event. One thing you can do to prevent MouseOver events is to check the MouseOver events for your TreeViewItems. If your RoutedEventArgs.OriginalSource does not equal the parent, just return and manage your event handlers manually.
public void TreeViewItem_MouseOver(object sender, RoutedEventArgs e)
{
if (sender != e.OriginalSource) return;
}
Jeff Wain
2009-07-15 18:09:37
too bad there is no MouseOver event for a TreeViewItem...
Roel
2010-09-16 08:16:29
Sorry about that. I actually realized after writing this that we work with an overridden TreeViewItem class that implements MouseOver. If it does in fact work, Mahop's solution would be elegantly simple.
Jeff Wain
2010-09-17 00:44:14
A:
http://blogs.msdn.com/mikehillberg/archive/2006/09/21/MyTreeViewHelperIsMouseDirectlyOverItem.aspx
this link solved the problem, I did not try the Original Source idea.
Kamiikoneko
2009-07-15 18:56:49
+2
A:
Better - Try This link!!!! (Less than one line of code!!!) http://blogs.msdn.com/hulyap/archive/2008/07/07/mouseover-trigger-for-treeviewitem.aspx
Mahop
2010-01-14 14:44:07