A
A
Andrey2018-11-04 00:15:39
C++ / C#
Andrey, 2018-11-04 00:15:39

How to update ListView from string array in Xamarin.Forms?

Good day everyone!
Can you please tell me how can I update a ListView that is filled with values ​​from string[] on a page in Xamarin.Forms? In theory.
There are two lists on the page:

<ListView x:Name="listNomeHTTP" ItemsSource="{Binding Nome}" ItemSelected="nomList_Selected"/>
<ListView x:Name="listNom" ItemsSource="{Binding Nom}" ItemSelected="nomList_Selected"/>

Nom - for checking. It is in the constructor, and there are no problems with it, when you go to the page in the application, the list is full.
public string[] Nom { get;private set; }
Nom = new string[] { "Шляпа", "Кепка" };

There is a problem with Nome :(
The array is filled with values ​​from the web api. There are values ​​in the Nome property, but they are no longer displayed on the page.
Use INotifyPropertyChanged? I confess ... I can’t figure out how to connect it to the array
:( but the result is the same. The collection is filled, but there is nothing on the page.
Tell me what to read. Where to dig?
I would be glad for any advice!
Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey, 2018-11-04
@andrey71

Happened! I spied the idea on the msdn forum!
I didn't think of it right away...

string[] nom = (JsonConvert.DeserializeObject<string[]>(content));
                foreach (string n in nom)
                    Nome.Add(n);

The list is now displayed on the page.
Thanks to everyone who helped!

L
LiptonOlolo, 2018-11-04
@LiptonOlolo

Option 1: Use an ObservableCollection.
Option 2: implement INotifyPropertyChanged.
"tried - does not work" - so they tried not so.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question