The Community.Toolkit.Mvvm library helps to generate properties for fields using special attributes. How can this attribute be used to automate such a property? How to make such an entry?
using CommunityToolkit.Mvvm.ComponentModel;
public partial class InfoViewModel : BaseViewModel
{
private readonly A.Info _item;
public ViewModel(A.Info item)
{
_item = item;
}
public ViewModel()
{
_item = new A.DateInfo();
}
//[ObservableProperty]
//private string year;
public string Year
{
get => _item.Year;
set
{
_item.Year = value;
OnPropertyChanged(nameof(Year));
}
}
}