Пример #1
0
        private void textBox_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
        {
            bool   found  = false;
            var    border = (resultStack.Parent as ScrollViewer)?.Parent as Border;
            var    data   = Prediction.Models();
            string query  = (sender as TextBox)?.Text;

            if (query.Length == 0)
            {
                resultStack.Children.Clear();
                border.Visibility = System.Windows.Visibility.Collapsed;
            }
            else
            {
                border.Visibility = System.Windows.Visibility.Visible;
            }
            resultStack.Children.Clear();
            foreach (var word in data)
            {
                if (word.ToLower().StartsWith(query.ToLower()))
                {
                    addItem(word);
                    found = true;
                }
            }
        }