SkalViewModel.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using Caliburn.Micro;
  2. using friaLabbar.Models;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. namespace friaLabbar.ViewModels
  10. {
  11. public class SkalViewModel : PropertyChangedBase
  12. {
  13. string name;
  14. public string Name
  15. {
  16. get { return name; }
  17. set
  18. {
  19. name = value;
  20. NotifyOfPropertyChange(() => Name);
  21. NotifyOfPropertyChange(() => CanSayHello);
  22. }
  23. }
  24. public bool CanSayHello
  25. {
  26. get { return !string.IsNullOrWhiteSpace(Name); }
  27. }
  28. public BindableCollection<int> AFewNumbers { get; set; }
  29. public BindableCollection<PersonModel> AFewPeople { get; set; }
  30. public SkalViewModel()
  31. {
  32. RandomPersonGenerator pg = new RandomPersonGenerator();
  33. AFewNumbers = new BindableCollection<int>(new List<int> { 1, 3, 3, 7, 58, 48, 690 });
  34. AFewPeople= new BindableCollection<PersonModel>(pg.GetPeople());
  35. }
  36. public void SayHello()
  37. {
  38. MessageBox.Show(string.Format("Hello {0}!", Name)); //Don't do this in real life :)
  39. AFewNumbers[2] = 15981;
  40. }
  41. }
  42. }