I have two combo boxes on a SL page. When Combo 1 updates, a service is called and populates Combo 2.
On the first call, 3 results are returned. When the combo box is expanded, you can see all 3 options.
On the second call, 4 results are returned. When the combo box is expanded, you can see 3 options, with a vertical scroll bar.
If I reload and do those steps in reverse, I get 4 rows the first call and 3 rows + a blank row on the second call. (No, the blank is not a record. It cannot be selected.)
It appears that the drop down list size keeps the first generated height.
How can I refresh the combo box max items shown after each service call?
Thanks!
Edit #1
The code follows the M-V-VM pattern. When the page loads, the Group1
populates the first combo box, and nothing is selected. When the user makes a selection, that selection is bound to Group1Selection.
<ComboBox ItemsSource="{Binding Path=Group1}" SelectedItem="{Binding Path=Group1Selection}" />
<ComboBox ItemsSource="{Binding Path=Group2}" SelectedItem="{Binding Path=Group2Selection}" />
In the viewmodel, in the set accessor of the Group1Selection
property, I have something like
set
{
if (group1Selection != value)
{
group1Selection = value;
PopulateGroup2();
OnPropertyChanged("Group1Selection");
}
}
Where PopulateGroup2 performs my service call async, gets the data, and puts that data into the exposed property of Group2
.
Under "normal" conditions, this isn't a problem, since most options have dozens of possible selections. However, a couple of the Group1
choices only have 3 or 4 child choices. If one of those is selected first, then the height of the ComboBox, for the rest of that application instance is set to 3 or 4, respectively, instead of maxing out at 8 shown items.
Following the M-V-VM pattern, there is no code in the code-behind.