I'm trying to use the MVVM Community Tool Kit meanly having my ViewModel inherits from the ObservableValidator to help me validate properties bound to the View control. According to the ObservableValidator documentation (https://learn.microsoft.com/en-us/dotnet/communitytoolkit/mvvm/observablevalidator) I can validate property as followings :
private string projectNumber;
[Required]
public string ProjectNumber
{
get => projectNumber;
set => SetProperty(ref projectNumber, value, true);
}
However my ViewModel are referencing properties through the Model ProjectMetadata , but I cant implement the Validation as follows:
[Required]
public string ProjectNumber
{
get => ProjectMetadata.ProjectNumber;
set => SetProperty(ref ProjectMetadata.ProjectNumber, value, true);
}
This code wont compile because the SetProperty is expecting a field and not propery. The question is how I can validate ViewModel Model properties.
Thanks