wpf - Button content not updated with PropertyChanged Notifications -
what trying is, when user click on button, content should change according coding. here code. have tried both, code behind way , xaml way of binding. not working.
<button x:name="header" content="{binding listheader}" click="headerclick"/> private string listheader; public string listheader { { return listheader; } set { listheader = value; if (propertychanged != null) { propertychanged(this, new propertychangedeventargs("listheader")); } } } public calendar() { this.selecteddate = datetime.now; this.listheader = selecteddate.tostring("mmmm"); } private void headerclick(object sender, routedeventargs e) { switch (stateoflist) { case statesoflist.listofdates: { this.listheader = selecteddate.year.tostring(); this.stateoflist = statesoflist.listofmonths; } break; case statesoflist.listofmonths: { this.filllist(listdatatypes.years); this.stateoflist = statesoflist.listofyears; } break; case statesoflist.listofyears: { } break; } }
you better bind content property name (listheader) , not variable name(listheader). change these 2 lines in code.
<button x:name="header" content="{binding listheader}" click="headerclick"/>
and
propertychanged(this, new propertychangedeventargs("listheader"));
Comments
Post a Comment