c# - ListPicker Data Binding and INotifyPropertyChanged -


so have 2 listpickers, device type , device name.

if select tablet in device type, want device name listpicker show options ipad, dell venue 8, etc.

if select phone in device type, want device name listpicker show options iphone, samsung galaxy, etc , on.

so how can go making data binding between these 2 listpickers , implement inotifypropertychanged changes in 1 listpicker dynamically reflected in other?

you can following :

in xaml :

<toolkit:listpicker x:name="devicetype" itemsource="{binding devicetypelist}" selecteditem="{binding selecteddevicetype, mode=twoway}"/> <toolkit:listpicker x:name="devicename" itemsource="{binding devicenamelist}" /> 

in code :

public class classname : notifychangements {     private yourtype selecteddevicetype;     public yourtype selecteddevicetype     {         { return selecteddevicetype; }         set         {             selecteddevicetype = value;             notifypropertychanged("selecteddevicetype");             majdevicename();         }     }      // later in code.     public void majdevicename()     {         // add code here fill devicenamelist according selecteddevicetype.     } } 

and notifychangements class :

using system.componentmodel; using system.runtime.compilerservices;  public class notifychangements : inotifypropertychanged     {         public event propertychangedeventhandler propertychanged;          public void notifypropertychanged(string property)         {             if (propertychanged != null)                 propertychanged(this, new propertychangedeventargs(property));         }          public bool notifypropertychanged<t>(ref t variable, t valeur, [callermembername] string property = null)         {             if (object.equals(variable, valeur)) return false;             variable = valeur;             notifypropertychanged(property);             return (true);         }     } 

you have add list<yourtype> devicenamelist attribute , call notifypropertychanged("devicenamelist") in setter of attribute in order make bind datas.

moreover, i'll let change variable , type names haven't provided code samples !


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -