I use xamarin (NOTE: next month i going to migrate MAUI) the problem is when i get a json response from post request with many fields like string fields and strings[] array, all the string fields show OK, but in listview show loads fields "empty", other words string [] array binding to listview load fields but show empty TextCells if array have 3 strings, show 3 empty fields, see the code: XAML:
<ListView ItemsSource="{Binding Specialities, Mode=TwoWay}" Grid.Row="8" Grid.Column="1"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand">
<ListView.ItemTemplate>
<DataTemplate>
<TextCell DetailColor="Black"
TextColor="Black"
Text="{Binding .}" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
VIEW MODEL:
private string[] _specialities;
public string[] Specialities
{
get => _specialities;
set => SetProperty(ref _specialities, value);
}
---------------CONTINUE
string resultadoRespuesta = await
response.Content.ReadAsStringAsync();
var problemDetails =
JsonConvert.DeserializeObject<AbogadosAtlasApi>
(resultadoRespuesta);
Nombres = problemDetails.FirtsNameOriginal;
Apellidos =
problemDetails.LastNameOriginal;
Celular = problemDetails.Celular;
Correo = problemDetails.Correo;
Cedula = problemDetails.Cedula;
Especialidad = problemDetails.speciality;
Ciudad = problemDetails.Ciudadperfil;
Plan = problemDetails.Plan;
Specialities = problemDetails.Specialities;
I
was playing with this code: foreach (string item in Specialities) { for (int ctr = 0; ctr < item.Length; ctr++) { Especialidadcon = item; } the result is Especialidadcon show OK with the right value
a part of the json response i get from the endpoint:
"firstName": "Juan Sebastián ",
"lastName": "Mario mena ",
"email": "jdsa@lsddsdex.ec",
"phone": "099434346840",
"city": "59cda262fe728437ce90ff81",
"isDelete": false,
ATTETION: jsonproperty is ok i bind from MODEL AbogadosAtlasApi
[JsonProperty("specialities")]
public string[] Specialities { get; set; }
"specialities": [
"5990d6ff3da48f4bd98c6914",
"5990d7273da48f4bd98c6918",
"5990d75a3da48f4bd98c691d",
"5a0a6087257e970afc9a9e73",
"5a0a60ac257e970afc9a9e76",
"5a13ecaf64de49704797d727"
],
"role": "5a0a60a3257e970afc9a9e75",