How to find a child from the styled listbox in WPF?
Listbox has the style in which itemtemplate consists of expander and inside expander there is a开发者_StackOverflow one more listbox, listbox inside the expander has to be accessed. So how to go ahead?
What data does the inner list box contain? Does your outer object contain a list of child objects as a property? If so, bind the inner listbox's ItemsSource
to that property.
If you want to access the listbox from code, this is probably what you're looking for: How to: Find DataTemplate-Generated Elements. It shows how to traverse the visual tree to find the generated elements. Using the visual tree is not a good solution usually though, so consider using data binding instead if at all possible.
精彩评论