Good afternoon, help me deal with the problem. There is a combobox:
<ComboBox x:Name="groupNum"SelectionChanged="groupNum_SelectionChanged"> There is a listbox:
<ListBox x:Name="groupSostav" ItemsSource="{Binding}"></ListBox> There is an event handler:
private void groupNum_SelectionChanged(object sender, SelectionChangedEventArgs e) { groupSostav.Items.Clear(); int n = int.Parse(groupNum.Text); for (int i = 0; i < n; i++) { groupSostav.Items.Add(n); } } Above in the constructor:
if (groupNum.SelectedValue == null) { groupNum.Text = "5"; } When choosing a value from ComboBox in ListBox, the number of fields should be updated (I chose 9 - it became 9 fields, I chose 5 - it became 5, etc.).
The whole thing starts off normally, 5 fields appear in the ListBox, then I select 4 for example, 5 fields remain, then 3 fields become 4, etc., that is, it takes the previous value, tell me how to make it normal?