获取WPF工具包AutoCompleteBox下拉列表中的项目计数

时间:2017-05-18 14:40:05

标签: c# wpf autocompletebox

有没有办法获取WPF工具包自动完成框下拉列表中当前显示的项目数?

2 个答案:

答案 0 :(得分:2)

或者你甚至可以这样做并避免循环:

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

答案 1 :(得分:0)

处理Populated事件:

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

    string text = count + " items shown!";
}