Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Reading values in a Listview of

$
0
0

Hello,

For the life of me I can't figure this one out. I present a listview to the screen. The user then enters quantities for each item, hence the entry cell.
When the user is finished entering the numbers for each item and clicks submit, I want to iterate the listview and save the values to a file, DB, new list, whatever.

Screen


Shopping List:

Oranges [1]
Apples [5]
Pears [2]
Bannanas [4]

[Submit]


Can someone please provide me an example of the binding properties.

I'm trying to do this:

List fruits;

List ecList = new List();

        var celltemplate = new DataTemplate(typeof(EntryCell));
        celltemplate.SetBinding(EntryCell.LabelProperty, "Label");
        celltemplate.SetBinding(EntryCell.KeyboardProperty, "Keyboard");
        celltemplate.SetBinding(EntryCell.TextProperty, "Text");

        foreach (var name in fruits)
        {
            EntryCell cell = new EntryCell()
            {
                Placeholder = "Place",
                Label = string.Format("{0}:", name),
                Text = string.Empty,
                Keyboard = Keyboard.Numeric,

            };

            ecList.Add(cell);
        }


        listView.ItemsSource = ecList;
        listView.ItemTemplate = celltemplate;

Then after the submit button is clicked, I want to read the values from the EntryCells

foreach(var item in ecList )
{
string itemName = item.Name;
string itemText = item.Text;
};

When I iterate the list, item.name is there, but nothing in the entry item.Text. Do I need to hold something in session?

I have spent two days on this with no luck, Help!

Kurt Radamaker
Phoenix, AZ


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>