Forum Discussion
tppegu
14 years agoContributor
You do exactly the same thing? From your first post it looked like you were looking for the TextBlock containing the string you wanted and calling AddToSelection on its parent. If the tree has been rearranged, the Parent property might not be reliable. My method is to ignore the TextBlock in favor of the "NativeUIAObject.Name" property of the ListBoxItem itself. That way, the object returned by the search is the same one you call AddToSelection on, and you don't have to rely on the Parent being correct and up to date. That method should always work, regardless of how "jumbled" the tree has become.
I'm not sure what you mean by revisting the listbox, but you should always search for the item you want, rather than trying to reuse a reference to the item from an earlier part of the test. Silverlight is free to reorganize and reuse the objects within list and combo boxes, so you can rarely assume that an old ListBoxItem reference is still good.
I'm not sure what you mean by revisting the listbox, but you should always search for the item you want, rather than trying to reuse a reference to the item from an earlier part of the test. Silverlight is free to reorganize and reuse the objects within list and combo boxes, so you can rarely assume that an old ListBoxItem reference is still good.