From 19037d6d4a7c8877607418f97e841414fa05065e Mon Sep 17 00:00:00 2001 From: Krzysztof KrzysiekSiemv Smaga Date: Mon, 17 Mar 2025 21:03:15 +0100 Subject: [PATCH] Dodano edycje danych osoby - Zmodyfikowano User.cs, DetailedViewModel.cs, DetailedPage.xaml oraz MainPage.xaml --- Model/User.cs | 42 +- Service/DataService.cs | 2 + View/DetailedPage.xaml | 16 +- View/MainPage.xaml | 9 +- ViewModel/DetailedViewModel.cs | 53 +- .../Navigation Between.AssemblyInfo.cs | 2 +- ...avigation Between.AssemblyInfoInputs.cache | 2 +- ....GeneratedMSBuildEditorConfig.editorconfig | 14 +- .../Navigation Between.assets.cache | Bin 97356 -> 97356 bytes obj/Debug/net9.0-android/R.txt | 8243 ++++++++--------- .../_Microsoft.Android.Resource.Designer.dll | Bin 711168 -> 699904 bytes .../net9.0-android/designtime/build.props | 4 +- .../libraryprojectimports.cache | 2 +- obj/Debug/net9.0-android/mauiimage.outputs | 54 +- .../Navigation Between.AssemblyInfo.cs | 2 +- ...avigation Between.AssemblyInfoInputs.cache | 2 +- ....GeneratedMSBuildEditorConfig.editorconfig | 14 +- .../Navigation Between.assets.cache | Bin 22161 -> 22161 bytes .../Navigation Between.AssemblyInfo.cs | 2 +- ...avigation Between.AssemblyInfoInputs.cache | 2 +- ....GeneratedMSBuildEditorConfig.editorconfig | 14 +- .../Navigation Between.assets.cache | Bin 22935 -> 22935 bytes ...avigation Between.csproj.nuget.dgspec.json | 10 +- obj/project.assets.json | 6 +- obj/project.nuget.cache | 4 +- 25 files changed, 4221 insertions(+), 4278 deletions(-) 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 @@ - - -