I find myself writing a lot of WPF apps with MVVM pattern lately. A common, and tedious, task is wrapping a domain object in a view model. I do this a lot:
public class DomainObject
{
public virtual int IntProperty { get; set; }
public virtual string StringProperty { get; set; }
}
public class DomainObjectViewModel : ViewModelBase
{
public int IntProperty
{
get { return DomainObject.IntProperty; }
set
{
if (Equals(value, DomainObject.IntProperty)) return;
DomainObject.IntProperty = value;
OnPropertyChanged(nameof(IntProperty));
}
}
public string StringProperty
{
get { return DomainObject.StringProperty; }
set
{
if (Equals(value, DomainObject.StringProperty)) return;
DomainObject.StringProperty = value;
OnPropertyChanged(nameof(StringProperty));
}
}
}
MVVM by it's nature requires a lot of typing. I have a bunch of live templates and other tricks to reduce that, but something I would love is the ability to copy my domain object properties, paste them into the view model class, highlight them, and transform them as needed. Is it possible?