diff --git a/Model/User.cs b/Model/User.cs index 6080689..086a968 100644 --- a/Model/User.cs +++ b/Model/User.cs @@ -1,7 +1,43 @@ +using System.ComponentModel; namespace Navigation_Between.Model; +public class User : INotifyPropertyChanged +{ + private string description; + private string email; -public class User { public int Id { get; set; } public string Name { get; set; } - public string Description { get; set; } -} \ No newline at end of file + public string Surname { get; set; } + + public string Description + { + get => description; + set + { + if (description != value) + { + description = value; + OnPropertyChanged(nameof(Description)); + } + } + } + + public string Email + { + get => email; + set + { + if (email != value) + { + email = value; + OnPropertyChanged(nameof(Email)); + } + } + } + + public event PropertyChangedEventHandler? PropertyChanged; + protected void OnPropertyChanged(string propertyName) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } +} diff --git a/Service/DataService.cs b/Service/DataService.cs index fb72414..8aa665d 100644 --- a/Service/DataService.cs +++ b/Service/DataService.cs @@ -16,6 +16,8 @@ public class DataService { }; } + // Dodawanie czy usuwanie elementów do listy w ObservableCollection NIE WYMAGA INotifyPropertyChanged, + // Stosujemy to w momencie, kiedy modyfikujemy wlaściwość naszego elementu, np.: Imie osoby o ID nr. 1 public ObservableCollection GetUsers() => users; public void AddUser(User user) { diff --git a/View/DetailedPage.xaml b/View/DetailedPage.xaml index 9ab7764..15aacc8 100644 --- a/View/DetailedPage.xaml +++ b/View/DetailedPage.xaml @@ -1,9 +1,15 @@ - - -