.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.
When using the [ObservableProperty] attribute to generate the code for the observable property, the protection level of the generated setter is always public
API breakdown
public enum SetterProtection
{
Public,
Protected,
Private
}
[ObservableProperty(SetterProtection = SetterProtection.Private)]
private int _someValue;
Usage example
[ObservableProperty(SetterProtection = SetterProtection.Private)]
private int _someValue;
Breaking change?
No
Alternatives
I am not aware of any
Additional context
I do quite often want to provide readonly properties for binding in xaml. These properties should not be set from xaml. While I can make sure this is how things are done, I don't get any support from the Toolkit (and if the xaml is wrong and sets such a property, It will silently work instead of causing a binding error).
Overview
When using the [ObservableProperty] attribute to generate the code for the observable property, the protection level of the generated setter is always public
API breakdown
Usage example
Breaking change?
No
Alternatives
I am not aware of any
Additional context
I do quite often want to provide readonly properties for binding in xaml. These properties should not be set from xaml. While I can make sure this is how things are done, I don't get any support from the Toolkit (and if the xaml is wrong and sets such a property, It will silently work instead of causing a binding error).
Help us help you
Yes, but only if others can assist