1

Very simple question.

I have attached to the PreviewMouseLeftButtonDown event. I know this event Tunnels so the first item in the visual tree is going to get flagged as the e.OriginalSource.

Example:

I have a Grid named "MainGrid". This Grid contains a label.

If I setup a PreviewMouseLeftButtonDown event on that grid and I click on the the label, the PreviewMouseLeftButtonDown event will be triggered.

The MouseButtonEventArgs for this contains an OriginalSource (e.OriginalSource). Depending on where I click inside of the label, this might be a border...this might be a textblock or this might be a border.

I want to walk the visual tree and find "MainGrid". I know of the recursive ways to do this, but what if I don't know the type of the owner. I only know I want to find the owner (i.e. this needs to be generic).

Something like "e.OriginalSource.ORIGINAL_OWNER"

Will gladly elaborate if this is not clear.

Thanks

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
tronious
  • 1,547
  • 2
  • 28
  • 45

1 Answers1

1

It sounds like you are just looking for e.Source?

Justin Pihony
  • 66,056
  • 18
  • 147
  • 180