Thursday, April 21, 2011

Access SurfaceWindow from TagVisualization

Hi,

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

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

    HTH

    Isak Savo : 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.
  • 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

0 comments:

Post a Comment