Repository navigation
Replies: 1 comment
|
If you need custom getter logic, one option is to keep the observable property as the backing value and expose a separate computed property: [ObservableProperty]
private string? name;
public string DisplayName =>
string.IsNullOrEmpty(Name) ? "Default" : Name;
|
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I'm converting a legacy codebase to communitytoolkit and am currently facing a few instances where the getter of a proeprty I seek to replace has custom logic (e.g. a fallback value in case the backing field is an empty string). The generated code fia a partial property is
get => field;would it be possible to define the getter in the user code instead?All reactions