You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The documentation gives great instructions on how to use SetProperty for wrapping objects such as EF generated objects, but since it's very repetitive it seems ideally suited to an attribute similar to [ObservableProperty].
I'm thinking something along the lines of these two variations
public partial class MyObjectWrapper : ObservableObject
{
[ObservablePropertyMapping("Description")]
private MyObject wrappedEntity;
[ObservableWrappedProperty(nameof(wrappedEntity),"Title")]
public string TitleByANewName;
}
expanding to
public partial class MyObjectWrapper : ObservableObject
{
public string Description
{
get => wrappedEntity.Description;
set => SetProperty(wrappedEntity.Description, value, wrappedEntity, (e, d) => e.Description= d));
}
public string TitleByANewName
{
get => wrappedEntity.Title;
set => SetProperty(wrappedEntity.Title, value, wrappedEntity, (e, t) => e.Title = t));
}
}
There'd also probably need to be some kind of [NotifyPropertyChangedFor] attribute for generating code for triggering property changes in other dependant properties as below
public partial class MyObjectWrapper : ObservableObject
{
public string Title
{
get => wrappedEntity.Title;
set
{
if (SetProperty(wrappedEntity.Title, value, wrappedEntity, (e, t) => e.Title = t))
{
OnPropertyChanged(nameof(ListTitle));
};
}
}
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The documentation gives great instructions on how to use SetProperty for wrapping objects such as EF generated objects, but since it's very repetitive it seems ideally suited to an attribute similar to
[ObservableProperty]
.I'm thinking something along the lines of these two variations
expanding to
There'd also probably need to be some kind of
[NotifyPropertyChangedFor]
attribute for generating code for triggering property changes in other dependant properties as belowBeta Was this translation helpful? Give feedback.
All reactions