i am using CommunityToolkit to configure the binding properties in the view model, but in some cases I would like to set the property only as readonly. So I am tryiung this:
[ObservableProperty]
public MyType _myProperty{ get; private set; }
But this is only possible with fields, not with properties.
Is it possible to set a readonly property with CommunityToolkit?
Thanks.
ObservablePropertyis the incorrect thing for you here then, since the general idea behind using that is that you get the property change notifications and all the other goodness wired up automatically. Can you explain a little more about how you're using this, and why you wouldn't want it to be set from your view?[ObservableProperty(isSetterPrivate: true)].