开发者

How to find a child from the styled listbox in WPF?

开发者 https://www.devze.com 2022-12-15 23:05 出处:网络
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

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

精彩评论

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

关注公众号