开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜