Forum Discussion
tppegu
14 years agoContributor
Ah, multiple TextBlocks in each item, so the NativeUIAObject.Name is probably just a class name that's the same for all items, right? Tricky.
I agree that TC does have problems with Silverlight objects, and it certainly needs work, but I've found that it's not always as bad as it appears. It seems to me that the real problem lies with the Object Browser panel. The tree that you see in the Object Browser does often get badly out of sync with what's really on screen, and that seems to interfere with scripts. But in general I have found that there are no problems while actually running scripts that deal with the same objects, as long as I haven't used the Object Browser beforehand. That means that I often have to restart TC or go through various other rituals in order to get a script written, but once it's written it works OK at runtime. Very annoying, yes, but manageable.
There may be another workaround for your situation. I assume that you are searching for the desired TextBlock by calling FindChild from the ListBox object, is that right? Instead of that, you may be better off if you first use FindAllChildren to find all the visible ListBoxItems, and from each of those call FindChild to find the TextBlock within and see if it's the one you're looking for. If it is, you already have what should be a valid and correct reference to its parent. If you get through the whole set of visible ListBoxItems without finding the item you want, then scroll a bit, refresh, and try it all again.
I agree that TC does have problems with Silverlight objects, and it certainly needs work, but I've found that it's not always as bad as it appears. It seems to me that the real problem lies with the Object Browser panel. The tree that you see in the Object Browser does often get badly out of sync with what's really on screen, and that seems to interfere with scripts. But in general I have found that there are no problems while actually running scripts that deal with the same objects, as long as I haven't used the Object Browser beforehand. That means that I often have to restart TC or go through various other rituals in order to get a script written, but once it's written it works OK at runtime. Very annoying, yes, but manageable.
There may be another workaround for your situation. I assume that you are searching for the desired TextBlock by calling FindChild from the ListBox object, is that right? Instead of that, you may be better off if you first use FindAllChildren to find all the visible ListBoxItems, and from each of those call FindChild to find the TextBlock within and see if it's the one you're looking for. If it is, you already have what should be a valid and correct reference to its parent. If you get through the whole set of visible ListBoxItems without finding the item you want, then scroll a bit, refresh, and try it all again.