Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. public View1ViewModel()
  2. {
  3. contactesPopulate();
  4. GridContactes = new ObservableCollection<contacte>(db.contactes.ToList());
  5. FilteredContactes = GridContactes;
  6. }
  7.  
  8. private ObservableCollection<contacte> _gridContactes;
  9. public ObservableCollection<contacte> GridContactes
  10. {
  11. get
  12. {
  13. return _gridContactes;
  14. }
  15. set
  16. {
  17. if (_gridContactes == value)
  18. return;
  19.  
  20. _gridContactes = value;
  21. NotifyPropertyChanged();
  22. }
  23. }
  24.  
  25. private ObservableCollection<contacte> _filteredContactes;
  26. public ObservableCollection<contacte> FilteredContactes
  27. {
  28. get
  29. {
  30. return _filteredContactes;
  31. }
  32. set
  33. {
  34. if (_filteredContactes == value)
  35. return;
  36.  
  37. _filteredContactes = value;
  38. NotifyPropertyChanged();
  39. }
  40. }
  41.  
  42. private void Filter()
  43. {
  44. _filteredContactes.Clear();
  45. foreach (contacte c in _gridContactes)
  46. {
  47. if (c.cognoms.Contains("a"))
  48. {
  49. _filteredContactes.Add(c);
  50. }
  51. }
  52. }
  53.  
  54. public const string TextFilterPropertyName = "TextFilter";
  55. private string _TextFilter;
  56. public string TextFilter
  57. {
  58. get { return _TextFilter; }
  59. set
  60. {
  61. _TextFilter = value;
  62. NotifyPropertyChanged();
  63. Console.WriteLine("filtering");
  64. Filter();
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement