xaml - Bound Item To DependencyProperty Not Propagating Value -
this property defined inside custombutton:
public bool ison { { return (bool)getvalue(isonproperty); } set { setvalue(isonproperty, value); if (ison) visualstatemanager.gotostate(this, "on", true); else visualstatemanager.gotostate(this, "off", true); } } public static readonly dependencyproperty isonproperty = dependencyproperty.register("ison", typeof(bool), typeof(imagebutton), new propertymetadata(false));
in xaml bound boolean list below:
ison="{binding sender.ispinned, mode=oneway}"
and sender.ispinned raises propertychange
public bool ispinned { { return _model.ispinned; } set { _model.ispinned = value; raisepropertychanged("ispinned"); } } protected void raisepropertychanged(string propertyname) { propertychangedeventhandler handler = propertychanged; if (handler != null) { handler(this, new propertychangedeventargs(propertyname)); } } public event propertychangedeventhandler propertychanged;
when ispinned changed, ison doesn't see change @ all. when save data , refresh ui, change reflected on ison.
it seems propertychangedeventhandler not implemented when debugged, calls event.
i believe code (not shown) changing _model.ispinned
directly , not changing ispinned
property has binding notification. lead update failure ison
.
the backing variable _model.ispinned
used ispinned
cannot changed other ispinned
setter; such change can noticed ison
.
one has change ispinned
property directly (which subsequently changes _model.ispinned
) otherwise binding cannot pick on changes backing store _model.ispinned
.
-- or ---
when variable _model.ispinned
changed outside of setter, call raisepropertychanged("ispinned");
signify change ison
.
Comments
Post a Comment