1

I'm looking for an easy way to access my main SurfaceWindow from a TagVisualization that I have. The scenario is that I want to pass along data from my TagVisualization back to the SurfaceWindow. Is there an easy way to do this?

Thanks

skaffman
  • 398,947
  • 96
  • 818
  • 769
Rajen
  • 41
  • 3

2 Answers2

1

TagVisualization inherits from FrameworkElement, so a Parent property is available. You can climb the hierarchy that way until you get to the SurfaceWindow.

HTH

Sascha
  • 10,231
  • 4
  • 41
  • 65
  • keep in mind that the Parent property only walks the logical tree. If you are inside a template, you'll never reach the window using this method. – Isak Savo May 04 '10 at 17:34
0

Generally, I'd recommend you to think about your overall architecture of your application, since you're introducing a tighter coupling between your controls that is normally desirable.

That said, you can walk your apps visual tree using the VisualTreeHelper

This stack overflow question has a lot of details about finding controls, and especially the answer containing the FindVisualParent helper method

Community
  • 1
  • 1
Isak Savo
  • 34,957
  • 11
  • 60
  • 92