wpf - mvvm - prismv2 - INotifyPropertyChanged -
since long , prolapsed , doesnt ask coherent question:
1: proper way implement subproperties of primary object in viewmodel?
2: has found way fix delegatecommand.raisecanexecutechanged issue? or need fix myself until ms does?
for rest of story...continue on.
in viewmodel have doctor object property tied model.doctor, ef poco object. have onpropertychanged("doctor") in setter such:
private property doctor() model.doctor return _objdoctor end set(byval value model.doctor) _objdoctor = value onpropertychanged("doctor") end set end property
the time onpropertychanged fires if whole object changes. wouldnt problem except need know when properties of doctor changes, can enable other controls on form(save button example). have tried implement in way:
public property firstname() string return _objdoctor.firstname end set(byval value string) _objdoctor.firstname = value onpropertychanged("doctor") end set end property
this taken xamlpowertoys controls karl shifflet, have assume correct. life of me cant work.
i have included prism in here because using unity container instantiate view , singleton. getting change notification viewmodel via eventaggregator populates doctor new value. reason doing because of prism's delegatecommand. maybe real issue.
it appears there bug in delegatecommand not fire raisecanexecutechanged method on commands implement , therefore needs fired manually. have code in onpropertychangedeventhandler. of course isnt implemented through icommand interface either have break , make properties delegatecommand(of x) have access raisecanexecutechanged of each command.
2: has found way fix delegatecommand.raisecanexecutechanged issue? or need fix myself until ms does?
use josh smith's relaycommand instead of delegatecommand. fixes issue canexecute commands not being raised, , doesn't leak memory delegatecommand:
"it delegates event subscription commandmanager.requerysuggested event. ensures wpf commanding infrastructure asks relaycommand objects if can execute whenever asks built-in commands."
Comments
Post a Comment