hi, everyone,
I face the following problem,
My app is simple, there is a listview contains 10 items each item contains picker and label,
and I have a save button at the end of the page
when clicking a button I need to collect data that is selected from each picker in the list
the problem is that when I scroll the list down NullReferenceException appears
I don't find a way to solve it
can anybody help, please?
the picture attached describes the problem.
any help, Please!
@hadeel I've tested a basic demo and it works as except. The selectedItem of Picker
should be convert to the model class type instead of a property, try to change the code like follow.
private void OnPickerSelectedIndexChanged(object sender, System.EventArgs e) { var item = (Picker)sender; var selectedItemDegree = item.SelectedItem as PickerItem; int value = selectedItemDegree.value; }
Answers
@hadeel I've tested a basic demo and it works as except. The selectedItem of
Picker
should be convert to the model class type instead of a property, try to change the code like follow.@Jarvan
can you show me your full demo code Please?
I try to change the code as you tell me but the problem still exists
@hadeel Here is the demo file you can refer to.
@Jarvan thank you so much.
I think that there is another reason for that which is the ListView performance,
so I removed the following property from listview tag in my XAML code
CachingStrategy="RecycleElement"
then it works fine.