question

RogerSchlueter-7899 avatar image
0 Votes"
RogerSchlueter-7899 asked ·

TakeWhile taking all elements despite selection criterion

I am trying to create a progressive ComboBox. For this example I am using a Person Class with properties ID and Name.

The following code almost implements the desired functionality:

 Dim ocPeople As New ObservableCollection(Of Person)
 Dim cvsPeople As CollectionViewSource
 Dim tb As TextBox
 Dim pup As Popup

 Private Sub Me_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
         GetData()
         tb = DirectCast(cbo.Template.FindName("PART_EditableTextBox", cbo), TextBox)
         AddHandler tb.TextChanged, AddressOf Search
         cvsPeople = DirectCast(Resources("cvsPeople"), CollectionViewSource)
         cvsPeople.Source = ocPeople
         cbo.SelectedIndex = -1
         pup = DirectCast(cbo.Template.FindName("PART_Popup", cbo), Popup)
     End Sub
    
     Public Sub Search(sender As Object, e As TextChangedEventArgs)
         cbo.ItemsSource.Cast(Of Person).TakeWhile(Function(p) p.Name.StartsWith(tb.Text))
         If pup IsNot Nothing Then pup.IsOpen = True
     End Sub

The problem is that TakeWhile is not working. It returns all the items in the ComboBox, not just the ones matching the stated criterion.

Ignore the Tag as they are implemented yet.

service-fabric-standalone
· 2
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@RogerSchlueter-7899 Is this issue related to any Azure service? Please let me know so that I can redirect it to the right team.

0 Votes 0 ·

No, it uses SQL Server as the data store. I don't think the source of the data is relevant to the problem.

0 Votes 0 ·

0 Answers