I have a problem with my code. I use a listbox and a observable collection to add the data to the list. the code looks like this:
ListData actualData;
ObservableCollection<ListData> data;
public Calculate()
{
InitializeComponent();
data = new ObservableCollection<ListData>();
newData();
listbox1.ItemsSource = data;
}
private void newData()
{
actualData = new ListData("1", "2", "3");
data.Add(actualData);
}
Now, I have a button which, for example, changes actualData
but I cant see the change in the list.
the button looks like:
private void button1_Click(object sender, RoutedEventArgs e)
{
actualData.first = "12";
}
I found a workaround:
listbox1.ItemsSource = null;
listbox1.ItemsSource = data;
but this is not a good solution, what is wrong here?