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

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -