I have a WrapPanel that contains 5 XamTrees. I want to be able to get a reference to the XamTreeItem that was clicked.
My first attempt was to set a MouseLeftButtonUp event handler on the WrapPanel and use e.OriginalSource to get the reference to the XamTreeItem. But, instead, e.OriginalSource returned the TextBlock associated with the XamTreeItem.
Am I going to have to programmatically subscribe to the event for each and every XamTreeItem? Or, is there a more elegant and efficient way to handle thie?
Yes. Sorry, I just hadn't taken the time to get back here and reply.
Thank you,
Joe
Hello,
Were you able to resolve your issue?
Valerie
You can walk the visual tree to get the XamTreeItem:
TextBlock tb = (TextBlock)e.OriginalSource;
DependencyObject dob = VisualTreeHelper.GetParent(tb);
{
dob =VisualTreeHelper.GetParent(dob);
if (dob == null)
break;
}