I have a problem of performance with an observable collection. This foreach is binded with a combobox (MaAcquisition is an observable collection) :
for (double i = 0.1; i <= 5; i += 0.1)
{
MaAcquisition.Add($"{i:0.0}");
x++;
}
With this foreach, every loop, I bind value to combobox, it's very slow.
So to improve this I do this :
List<String> MaAcquisitionList = new List<String>();
for (double i = 0.1; i <= 5; i += 0.1)
{
MaAcquisitionList.Add($"{i:0.0}");
x++;
}
MaAcquisition = MaAcquisitionList;
It's working but after this "foreach" I do a binding to choose the "selectedItem" =>
SelectedMa = MaAcquisition[x - 1];
Selected item is binded to my combobox and it's not working (the selected item is blank).
<ComboBox ItemsSource="{Binding MaAcquisition, Mode=TwoWay}" SelectedItem="{Binding SelectedMa, Mode=TwoWay}" IsEnabled="{Binding PreheatingDisable}"/>
And finally, there is the code for "SelectedMa" :
public string SelectedMa
{
get { return _selectedMa; }
set
{
_selectedMa= value;
OnPropertyChanged();
RaisePropertyChanged();
}
Do you have an idea for this problem?
Thank's.
SelectedMa
property/field? – slugster