c# - Binding CheckBox.Visibility and CheckBox.IsChecked -


i'm developing windows phone 8 application listbox datatemplate:

<phone:phoneapplicationpage.resources>     <datatemplate x:key="localizationitemtemplate">         <border borderbrush="black" borderthickness="2" cornerradius="8" background="#ff003847" height="80">             <stackpanel x:name="contentgrid" margin="4" orientation="horizontal">                 <checkbox x:name="selectedcheck" visibility="{binding checkboxvisibility}" ischecked="{binding ischecked}"                         horizontalalignment="left" margin="10,0,0,0" verticalalignment="center" isenabled="false"/>                 <textblock x:name="locationname" textwrapping="wrap" text="{binding content}" verticalalignment="center" fontsize="24" horizontalalignment="left" margin="10,0,0,0"/>             </stackpanel>         </border>     </datatemplate> </phone:phoneapplicationpage.resources> 

i'm using observablecollection<locationtoshow> itemssource:

public class locationtoshow : aritem {     public double distance { get; set; }      public string formateddistance     {                 {             if (distance == double.nan)                 return string.empty;             else                 return string.format("{0} metros", distance.tostring("n0"));         }     }      public visibility checkboxvisibility { get; set; }      public bool ischecked { get; set; } } 

but, when change checkboxvisibility or ischecked don't see checkbox appears or checked it.

how can fix problem?

implement inotifypropertychanged on class locationtoshow notify ui update on property change.

refer - how implement inotifypropertychanged notification.

public class locationtoshow : aritem, inotifypropertychanged {     public event propertychangedeventhandler propertychanged;     // create onpropertychanged method raise event      protected void onpropertychanged(string name)     {         propertychangedeventhandler handler = propertychanged;         if (handler != null)         {            handler(this, new propertychangedeventargs(name));         }      }       private bool ischecked;      public bool ischecked       {           { return ischecked; }          set          {             if (ischecked != value)             {                ischecked = value;                onpropertychanged("ischecked");             }          }      } } 

change other properties follow same pattern in case want ui refresh on property change in class.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -