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

Is it possible to get the index # from the listboxitem?

2 Answers 132 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ray Lin
Top achievements
Rank 1
Ray Lin asked on 14 Jun 2010, 10:45 PM

Hi,

If I have 10 items in my listboxitem, is it possible to get the index # from it?

 

For example, if I click the last item, the code looks like the following one.

 

 

listboxitem[9]: Is it possible for me to add code and get 9 here?

 

Thanks

 

Ray

 

public ArtOfTest.WebAii.Silverlight.UI.ListBoxItem ListboxItem

                {

                    get

                    {

                        return Get<ArtOfTest.WebAii.Silverlight.UI.ListBoxItem>("XamlTag=listbox", "automationid=acctTree", "|", "XamlPath=/grid[0]/border[0]/scrollviewer[automationid=ScrollViewer]/border[0]/grid[0]/scrollcontentpresenter[name=ScrollContentPresenter]/itemspresenter[0]/virtualizingstackpanel[0]/listboxitem[9]");

                    }

                }

2 Answers, 1 is accepted

Sort by
0
Missing User
answered on 14 Jun 2010, 11:44 PM
Hello Ray,

Thanks for the question. You can try clicking on the ListBox Item, then customize it in code. Here is a code example to get the index based on this demo page's ListBox that contains numbers that clicks on 'Four':

[CodedStep(@"Click on Item32Listboxitem", RequiresSilverlight = true)]
  public void WebAiiTest4_CodedStep2()
  {
      // Click on Item32Listboxitem
      Pages.SilverlightControls.SilverlightApp.Item32Listboxitem.User.Click(ArtOfTest.WebAii.Core.MouseClickType.LeftClick, 14, 10, ArtOfTest.Common.OffsetReference.TopLeftCorner);
      ListBox b = Pages.SilverlightControls.SilverlightApp.Item32Listboxitem.Parent<ListBox>();
      b.Refresh();
      int i = b.SelectedIndex;
  }

Please let me know if you have any questions on the above.

Kind 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
Missing User
answered on 17 Jun 2010, 04:27 PM
Hello again Ray,

Just wanted to check back to see if you were able to successfully apply the sample code to your test project and SL application.

All the best,
Nelson
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
Tags
General Discussions
Asked by
Ray Lin
Top achievements
Rank 1
Answers by
Missing User
Share this question
or