c# - ListPicker "SelectedItem must always be set to a valid value" -


i try clear (and add) items listpicker, when app have clear of items error - "selecteditem must set valid value". code:

<toolkit:listpicker x:name="select" horizontalalignment="right" margin="0,135,30,0" verticalalignment="top" width="195" height="64" d:layoutoverrides="horizontalalignment" borderbrush="{x:null}" fontfamily="arial" fontweight="bold" fontsize="32" style="{staticresource listpickerstyle1}" borderthickness="0" datacontext="{binding}">     <toolkit:listpicker.background>         <imagebrush stretch="fill" imagesource="list_picker.png"/>     </toolkit:listpicker.background> 

and action button

private void button_tap(object sender, system.windows.input.gestureeventargs e) {     select.items.clear(); //here error     (int = 0; < arrays.length; i++)     {         select.items.add(arrays[i]);     } } 

i try options, doesn't work too.

private void button_tap(object sender, system.windows.input.gestureeventargs e) select.selecteditem = null; // here error     select.items.clear();     (int = 0; < arrays.length; i++)     {         select.items.add(arrays[i]);     } } 

to clear selection should use:

select.selecteditems.clear(); 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -