Changing the selected item

6 posts, 0 answers
  1. Tareq
    Tareq avatar
    36 posts
    Member since:
    Jun 2011

    Posted 12 Jul 2011 Link to this post

    hi, i need to change the selected item in code. i used to do that using the selectedIndex
    the items am using are objects from a class i made. 

  2. Deyan
    Admin
    Deyan avatar
    2039 posts

    Posted 12 Jul 2011 Link to this post

    Hello Tareq,

    You can use the SelectedItem property to change the selection in RadDataBoundListBox. You can set it to an object at a specified index within your source collection and this item will become selected in RadDataBoundListBox.

    Greetings,
    Deyan
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. DevCraft banner
  4. Tareq
    Tareq avatar
    36 posts
    Member since:
    Jun 2011

    Posted 12 Jul 2011 Link to this post

    its not working, or maybe am doing something wrong, heres my code:

    private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
    {
        XDocument loadedData = XDocument.Load("EngToAra.xml");
        var data = from query in loadedData.Descendants("word")
                   select new Ara
                   {
                       Arabic = (string)query.Element("arabic"),
                       English = (string) query.Element("english")
                   };
        List<Ara> d = data.ToList<Ara>();
        ara = d;
        radListBox.ItemsSource = data;
    }

    this is my Page Load, and this a button even to select the data:
    private void button1_Click(object sender, RoutedEventArgs e)
    {
        radListBox.SelectedItem = ara[100];
    }
  5. Deyan
    Admin
    Deyan avatar
    2039 posts

    Posted 12 Jul 2011 Link to this post

    Hello Tareq,

    Thanks for writing.

    Based on what I am seeing in your code snippet  I think that the selection should work as expected. Could you please prepare a small demo project that reproduces the issue and send it to us in a new support ticket so that we can see what actually goes wrong and thus be able to further assist you.

    Thanks for your time.

    Greetings,
    Deyan
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  6. Tareq
    Tareq avatar
    36 posts
    Member since:
    Jun 2011

    Posted 12 Jul 2011 Link to this post

    where should i send it to? and whats support ticket?



    EDIT: never mind, i got it.
  7. Tareq
    Tareq avatar
    36 posts
    Member since:
    Jun 2011

    Posted 12 Jul 2011 Link to this post

    i got it, it was the assigning thingy in the load event, i should just assign the item source to the List instead of the var data.

    thanks,

    private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
    {
        XDocument loadedData = XDocument.Load("EngToAra.xml");
        var data = from query in loadedData.Descendants("word")
                   select new Ara
                   {
                       Arabic = (string)query.Element("arabic"),
                       English = (string) query.Element("english")
                   };
        List<Ara> d = data.ToList<Ara>();
        ara = d;
       // radListBox.ItemsSource = data;
         radListBox.ItemsSource = ara;
    }
Back to Top
DevCraft banner