It's somewhat problematic to navigate the VisualTree. Sometimes even looking
at the XAML isn't evident which controll will be the parent as you would
need not only to know your XAML, but also the ControlTemplates the define
the controls that you're using.
A while ago I created some extensions for the VisualStateManager that can
help in this and other types of scenarios.

You can see part
1<http://miguelmadero.blogspot.com/2008/07/use-visualtreehelper-to-navigate.html>
 and part 
2<http://miguelmadero.blogspot.com/2008/07/use-visualtreehelper-to-navigate_18.html>


For this escenario with the Extension method we could use the following
syntax:

ListBoxItem lbi = button.GetParent<ListBoxItem>();

The code is available in my blog. I've added a couple more methods, if you
find it interesting, just e-mail me and I can send you the updated version.
--------------------------------------------------------------------------------
Support procedure: https://www.codify.com/lists/support
List address: [email protected]
Subscribe: [email protected]
Unsubscribe: [email protected]
List FAQ: http://www.codify.com/lists/ozsilverlight
Other lists you might want to join: http://www.codify.com/lists

Reply via email to