Get Count of Items in WPF Toolkit AutoCompleteBox Dropdown

226 Views Asked by At

Is there a way to get the count of the items currently showing in the dropdown in a WPF toolkit autocompletebox?

2

There are 2 best solutions below

0
mm8 On BEST ANSWER

Handle the Populated event:

private void AutoCompleteBox_Populated(object sender, PopulatedEventArgs e)
{
    int count = 0;
    foreach (var item in e.Data)
        count++;

    string text = count + " items shown!";
}
0
Drew Jex On

Or you could even just do this and avoid the loop:

private void AutoCompleteBox_Populated(object sender, PopulatedEventArgs e)
{
   int count = ((ReadOnlyCollection<object>)e.Data).Count;
}