.NET Community Toolkit is a collection of helpers and APIs that work for all .NET developers and are agnostic of any specific UI platform. The toolkit is maintained and published by Microsoft, and part of the .NET Foundation.
The alternative is to instantiate RelayCommand by hand.
The other alternative is to use a class which has the record as its member, but it is too verbose:
public partial class DataClassVM(DataRecord dr)
{
[RelayCommand]
private void Add(int newStuff) => dr.ListOfStuff.Add(newStuff);
// expose if necessary
public IList<int> DataRecord => dr.ListOfStuff;
public int Stuff => dr.Stuff;
}
Overview
Records should also be able to generate
RelayCommand
just like classes do.API breakdown
No new API
Usage example
Data layer has a record:
In the MVVM layer we want to provide commands to add or remove from the ListOfStuff:
Inside
DataRecordVM
I'd like to add to the listBreaking change?
No
Alternatives
The alternative is to instantiate
RelayCommand
by hand.The other alternative is to use a class which has the record as its member, but it is too verbose:
Additional context
No response
Help us help you
Yes, I'd like to be assigned to work on this item