views:

611

answers:

0

How to update the selectedindex of Combo box in Silverlight3 within Dataform. I am also using RIA. I tried updating in both Dataform_Loaded and Dataform_contentloaded the object is not created at that time. I get out of range error though I am seeting the selectedindex = 0;

Here is the code

    private void RacesForm_Loaded(object sender, RoutedEventArgs e)
    {
        ComboBox cbRaceTypes = (ComboBox)RacesForm.FindNameInContent("cmboxRaceType");
         cbRaceTypes.ItemsSource = _horseRaceContext.RaceTypes;
         cbRaceTypes.UpdateLayout();
         _horseRaceContext.Load(_horseRaceContext.GetRaceTypesQuery());

         cbRaceTypes.SelectedIndex = 0;


    }