This morning I fought the โslowโ WPF ComboBox and would like to know if anyone has any tips on debugging such a problem.
Say I have two ComboBoxes, A and B. When A changes, the elements in B also change. Each ComboBox has its own SelectedItem and ItemsSource data bindings as follows:
<ComboBox Grid.Column="1" ItemsSource="{Binding Names}" SelectedItem="{Binding CurrentName, Mode=TwoWay}" Margin="3" MinWidth="100" />
<ComboBox Grid.Column="1" Grid.Row="1" ItemsSource="{Binding SubNames}" SelectedItem="{Binding CurrentSubName, Mode=TwoWay}" Margin="3" MinWidth="100" />
Whenever the list in B needs to change, I do this by clearing the substitutions, and then re-adding the entries based on SelectedItem to A. This is because rewriting the sub-castle with the new one ObservableCollection<string>breaks the data binding.
Everything on one computer works as you expected. Select "A", then press "B" and new items will appear immediately. On another computer, when I do this, a pause of 5 seconds is performed before executing the ComboBox . The number of elements is the same. One of the differences is that on a slow machine in the background, there is hardware communication. I froze all these topics and it didnโt help.
My biggest problem is that I cannot figure out where to even start looking. I need to see what the system does when I click on the ComboBox. I use data binding, so I canโt put a breakpoint anywhere. I tried changing my subtitle ad from
public ObservableCollection<string> SubNames { get; set; }
to
private ObservableCollection<string> subnames_ = new ObservableCollection<string>();
public ObservableCollection<string> SubNames
{
get { return subnames_; }
set { subnames_ = value; }
}
getter setter, , , .
- , ? , - ComboBox, .