How to get next sibling of the element in visual tree? This elment is dataitem of the databound ItemsSource. My goal is get acces to sibling in code (assume that i have access to the element itself) and then use BringIntoView.
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For example, if your
ItemsControlis aListBox, the elements will beListBoxItemobjects. If you have oneListBoxItemand you want the nextListBoxItemin the list, you can use theItemContainerGeneratorAPI to find it like this:Here’s some sample XAML:
and the code-behind:
which results in:
This also works if the
ItemsControlis data-bound. If you only have the data item (not the corresponding user interface element), you can use theItemContainerGenerator.ContainerFromItemAPI to get the initial sibling.