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

RadComboBox- Invalid cross-thread access.

0 Answers 68 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Mario
Top achievements
Rank 1
Mario asked on 14 Nov 2011, 06:14 PM
Hello all,

I have one RadComboBox in my screen and I load the items from one table using one query in my screen:

private void Servicos_Loaded(object sender, RoutedEventArgs e)
        {
  
            var objDataContext = (IContentItem)this.DataContext;
            var Screen = (Microsoft.LightSwitch.Client.IScreenObject)objDataContext.Screen;
  
            Screen.Details.Dispatcher.BeginInvoke(() =>
            {
  
                var serviceResources = (Screen as EditableScheduleViewApptsGrid).ServiceToAppointment.ToList();
                this.actualServiceToAppt = serviceResources;
  
                foreach (SERVICE iten in serviceResources)
                {
                    RadComboBoxItem newItemServ = new RadComboBoxItem();
                    newItemServ.Content= iten.Name;
                    this.ServicosComboBox.Items.Add(newItemServ);
                }
                 
            });
  
        }

When I create the RadComboBoxItem,

RadComboBoxItem

 

 

newItemServ = new RadComboBoxItem();

 

 I get the error:
UnauthorizedAccessException was unhandled by user code
Invalid cross-thread access.

What I'm doing wrong???
How can I use Databind to put the data from the table (query) to the control RadComboBox??

Thanks.

No answers yet. Maybe you can help?

Tags
ComboBox
Asked by
Mario
Top achievements
Rank 1
Share this question
or