Infört Observable Property och observable object från Community Toolkit

This commit is contained in:
2025-10-13 08:59:26 +02:00
parent f5cc28f202
commit b2dbb9993f
21 changed files with 243 additions and 228 deletions

View File

@ -1,11 +1,12 @@
using Common.Library;
using CommunityToolkit.Mvvm.ComponentModel;
using GreadyPoang.EntityLayer;
using System.Collections.ObjectModel;
namespace GreadyPoang.ViewModelLayer;
public class ParticipantViewModel : ViewModelBase
public partial class ParticipantViewModel : ObservableObject
{
#region Constructors
public ParticipantViewModel() : base()
@ -17,41 +18,21 @@ public class ParticipantViewModel : ViewModelBase
{
_Repository = repo;
_sharingService = sharingService;
ParticipantObject = new Participant();
ParticipantList = new ObservableCollection<Participant>();
}
#endregion
#region Private Variables
private Participant? _ParticipantObject = new();
private ObservableCollection<Participant> _ParticipantList = new();
[ObservableProperty]
private Participant? participantObject;
[ObservableProperty]
private ObservableCollection<Participant> participantList;
private readonly IRepository<Participant>? _Repository;
private readonly IMethodSharingService<Participant> _sharingService;
#endregion
#region public Properties
public Participant? ParticipantObject
{
get { return _ParticipantObject; }
set
{
_ParticipantObject = value;
RaisePropertyChanged(nameof(ParticipantObject));
}
}
public ObservableCollection<Participant> ParticipantList
{
get { return _ParticipantList; }
set
{
_ParticipantList = value;
RaisePropertyChanged(nameof(ParticipantList));
}
}
#endregion
#region Get Method
public ObservableCollection<Participant> Get()
{