This is a migrated thread and some comments may be shown as answers.

Not able to find element on dynamic created item in Silverlight

2 Answers 113 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Rocky Fan
Top achievements
Rank 1
Rocky Fan asked on 10 Mar 2010, 06:54 PM

I got one issue on using WebAii 2.0 for testing Silverlight.

Environment: WIn7 x86 + VS 2010 RC. Silverlgiht 3.0 was build in VS2010 too.

Test case do :
  Launch browser
  Find the Silverlgiht in page and find its combobox inside, then select the combobox item.
  After combobox item was select, the product Silverlgith will grab new items to a listbox and filled the listbox.

All above steps work fine. And after the listbox items were filled, I can get find list box control, but from listbox control, I cannot find the listboxitem which were dynamic created!

 

 

 

ListBox listbox = app.FindName<ListBox>("lboxMetaDimensions");

 

IList

 

 

<ListBoxItem> listBoxItems = listbox.Find.AllByType<ListBoxItem>();

The listBoxItems == null.

I try to look into the all children items in all deepth levels recursively, and the result shows it does not contain listboxitem at all. Actually, when I use other Silverlight tool to inspect the v-tree, I can see the listboxitem.

Is any step I need to do after combox selection done and new item were filled in order to get new listboxitem?

Thanks.

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Missing User
answered on 10 Mar 2010, 10:36 PM
Hello Rocky Fan,

The framework may have an old copy of the Visual Tree if you say they are visible in the tree on another tool. Pleast try either:

app.VisualTree.Refresh();
ListBox listbox = app.FindName<ListBox>("lboxMetaDimensions");
IList <ListBoxItem> listBoxItems = listbox.Find.AllByType<ListBoxItem>();

or

ListBox listbox = app.FindName<ListBox>("lboxMetaDimensions");
listbox.Refresh();
IList <ListBoxItem> listBoxItems = listbox.Find.AllByType<ListBoxItem>();

Regards,
Nelson Sin
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Rocky Fan
Top achievements
Rank 1
answered on 11 Mar 2010, 12:22 AM
Thanks :) It works after call app.VisualTree.Refresh();
Tags
General Discussions
Asked by
Rocky Fan
Top achievements
Rank 1
Answers by
Missing User
Rocky Fan
Top achievements
Rank 1
Share this question
or