AutoCompleteBox max displayed items

May 31, 2011 at 8:09 AM

Hello,

Is there any way to limit the number of displayed items in the dropdown? I'm having performance issues when displaying large numbers of items (1000+).

Jun 1, 2011 at 12:39 PM
Eventually i figured this out by implementing a custom filter.
    public partial class TestView : UserControl
    {
        public TestView()
        {
            InitializeComponent();
            MyAutoCompleteBox.FilterMode = AutoCompleteFilterMode.Custom;
            MyAutoCompleteBox.TextChanged += new System.Windows.RoutedEventHandler(MyAutoCompleteBox_TextChanged);
            MyAutoCompleteBox.ItemFilter = (text, item) =>
            {
                if (count > 10) return false;
                if(item.ToString().StartsWith(text))
                {
                    count++;
                    return true;
                }
                return false;
            };
        }

        void MyAutoCompleteBox_TextChanged(object sender, System.Windows.RoutedEventArgs e)
        {
            count = 0;
        }

        private int count = 0;
    }

Hope this helps anyone else running into this. If there are any other better ways to do this, please share.