what best way submit window multiple usercontrols, each own viewmodel?
i have form, multiple child controls within it. form has viewmodel direct controls, , each of usercontrols have own viewmodel.
the number of usercontrols differ depending on user selection not same each time.
the form submitted in 1 go save button.
is case of upon save click, should loop usercontrols , save view models individually via reading datacontext? or there better way.
thanks
create compositecommand on parentviewmodel , pass dynamically created childviewmodels.
public readonly compositecommand saveallcommand;
//somewhere inside parent viewmodel
childviewmodel = new childviewmodel(this.saveallcommand);
then inside each of childviewmodels, register own save command saveallcommand
public childviewmodel(compositecommand saveallcommand) { saveallcommand.registercommand(new savechildcommand()); }
finally when execute saveallcommand in parent, childviewmodel's savecommand registered command executed well.
Comments
Post a Comment