Beispiel #1
0
        private void controlsSearchBox_TextChanged(ModernWpf.Controls.AutoSuggestBox sender, ModernWpf.Controls.AutoSuggestBoxTextChangedEventArgs args)
        {
            var suggestions = new List <string>();

            if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput)
            {
                var querySplit    = sender.Text.Split(' ');
                var matchingItems = _controlPages.Where(
                    item =>
                {
                    bool flag = true;
                    foreach (string queryToken in querySplit)
                    {
                        if (item.Content.ToString().IndexOf(queryToken, StringComparison.CurrentCultureIgnoreCase) < 0)
                        {
                            flag = false;
                        }
                    }
                    return(flag);
                });
                foreach (var item in matchingItems)
                {
                    suggestions.Add(item.Content.ToString());
                }
                if (suggestions.Count > 0)
                {
                    for (int i = 0; i < suggestions.Count; i++)
                    {
                        autoBox.ItemsSource = suggestions;
                    }
                }
                else
                {
                    autoBox.ItemsSource = new string[] { "No results found" };
                }
            }
        }
Beispiel #2
0
 private void Search_GamesList_Reset(ModernWpf.Controls.AutoSuggestBox sender, ModernWpf.Controls.AutoSuggestBoxTextChangedEventArgs args)
 {
     if (string.IsNullOrEmpty(sender.Text))
     {
         RefreshGamesList(Library.GetAllEntires());
     }
 }