I'm on my second WPF project and ran into a uncomfortable situation. This is my model:
public class Layout
{
public string Name { get; set; }
public Motor Motor { get; set; }
}
public class Motor
{
public string Property1 { get; set; }
...
public string Property150 { get; set; }
}
This is my MainViewModel:
public class MainViewModel : ViewModelBase
{
public Motor Motor {get; set;}
...
}
Ok, I have bound all 150 properties of the motor class to textboxes:
<TextBox Text="{Binding Layout.Motor.Property1}"/>
Problem 1) if I want to trigger an action whenever a user changes one of these, will I have to implement this 150 times??
private string property1 { get; set; }
public string Property1
{
get { return property1; }
set
{
property1 = value;
RaisePropertyChanged(() => Property1);
}
}
Problem 2) will I have to implement this in the MainViewModel, in the model "Motor" or would I need a "MotorViewModel"? Any of these would mean a lot of copy&paste and totally useless coding..
Thank you for any help and feedback!