English 中文(简体)
Xamarin Forms string [] array binding to listview load fields but show empty TextCells
原标题:

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",
问题回答

暂无回答




相关问题
Cannot pair with mac running Ventura

We have a Windows Server 2016 machine that we use to build our Xamarin projects. We recently upgraded our macOS to Ventura and since have not been able to pair Visual Studio to the mac. I have ...

Using C# library with Mono for Android from Java code?

There is a possibility to use C# library with Mono for Android from Java code? It s possible to do it from Objective-C to C# (MonoTouch) with the "--xcode" flag in the mtouch command. But there is an ...

Draw into UIImage

how can I draw into an existing UIImage using monotouch? I load an image: UIImage.FromFile("MyImage.png") Then I want to draw a string and some lines into this image. Does anyone has a code sample? ...

Writing Android apps in C# (Xamarin) [closed]

I m a C# programmer and want to write an Android app. I m a stubborn curmudgeon and refuse to write Java ever again (after switching to C# six years ago). Besides Mono and MonoDroid (and writing Java)...

access denied when i want to open up file

in xamarin android why access is denied when i want to BufferedStream my file? fileAddress= "/storage/emulated/0/Download/rename2.pdfl"; Reader = new BufferedStream(File.OpenRead(...

热门标签