I have a problem with a list, which is bound to a ComboBox
.
The List
:
private List<string> _CourseList = new List<string>();
public List<string> CourseList
{
get { return _CourseList; }
set
{
_CourseList = value;
OnPropertyChanged("CourseList");
}
}
XAML code of the ComboBox
:
<ComboBox x:Name="cbxCourse" Height="23" MinWidth="100" Margin="5,1,5,1" VerticalAlignment="Top" ItemsSource="{Binding Path=CourseList}" IsEnabled="{Binding Path=CanExport}" SelectedIndex="{Binding Path=CourseListSelectedIndex}" SelectedItem="{Binding Path=CourseListSelectedItem}" SelectionChanged="cbxCourse_SelectionChanged"/>
Now i fill the List
from another thread:
void Database_LoadCompleted(object sender, SqliteLoadCompletedEventArgs e)
{
foreach (DataTable Table in DataSetDict[CampagneList[0]].Tables)
{
CourseList.Add(Table.TableName);
}
}
Everything looks good, and the ComboBox
changed its items.
When I try to update the ComboBox
(CourseList
) in the MainThread with:
private void cbxCampagne_SelectionChanged(object sender, EventArgs e)
{
if (cbxCampagne.SelectedItem != null)
{
CourseList.Clear();
foreach (DataTable Table in DataSetDict[CampagneList[_CampagneListSelectedIndex]].Tables)
{
CourseList.Add(Table.TableName);
}
}
all Elements of CourseList
changed (I can see it in a Textbox
) but in the ComboxBox
nothing happens.
Any ideas?