Beispiel #1
0
 private void FilterPlayers()
 {
     if (Players == null)
     {
         return;
     }
     FilteredPlayers = Players?.Where(FilterPlayer).ToList();
     //// If only one player, select it
     //if (FilteredPlayers.Count() == 1)
     //    SelectedPlayer = FilteredPlayers.First();
     SelectedPlayer = FilteredPlayers.FirstOrDefault();
 }
Beispiel #2
0
        /// <summary>
        /// Filter the collection to match the filter and populate the observablecollection
        /// </summary>
        private void FilterCollection()
        {
            FilteredPlayers.Clear();
            if (string.IsNullOrEmpty(Filter))
            {
                return;
            }

            var _filteredPlayers = Players.Where(p => p.Name.StartsWith(Filter) && p.Name != Filter).OrderByDescending(p => p.LastMatch);

            if (_filteredPlayers.Count() == 0)
            {
                return;
            }

            foreach (vmPlayer Player in _filteredPlayers)
            {
                FilteredPlayers.Add(Player);
            }
        }