Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Need Help
please give me full solution

i am creating a Xamarin Form Page and there is Picker Control in my page .
i want to display a list in picker.and data is coming from the API. after that i am trying to Bind API Data with my Picker Control
My Problem is that
i am able to fetch the data but only single value is displaying only. only one value not complete list.

i am sending my codes which i am trying to do


GetAircraftCustomerDetails
this method is for API and result is coming from the API properly


please check full of codes and reply to me soon

What I have tried:

This is UI
<Picker x:Name="selectAircraft" Title="--Select--" ItemDisplayBinding="{Binding AircraftModel,Mode=TwoWay}" ItemsSource="{Binding aircraft}">


public async void GetAirCraftRegin()
      {
          if (!Util.CheckInternet())
          {
              return;
          }
          InputClass = new NRCMainInput();
          AircraftRegnList = new ObservableCollection<List<RootResultData>>();
          aircraft = new List<aircraftDetail>();
          WorkOrderApiHelper _workOrderApiHelper = new WorkOrderApiHelper();
          InputClass.OUID = 1;
          InputClass.AIRCRAFT_REG_NO = "123231";
          string Result = await _workOrderApiHelper.GetAircraftCustomerDetails(InputClass);
          if (!string.IsNullOrEmpty(Result))
          {

              var objdata = JsonConvert.DeserializeObject<RootResultData>(Result);
              foreach (var items in objdata.Result.ModelCust)
              {
                  aircraftDetail details = new aircraftDetail();
                  details.AircraftModel = items.AircraftModel;
                  aircraft.Add(details);

                  selectAircraft.ItemsSource = aircraft;

              }





          }

      }


internal async Task<string> GetAircraftCustomerDetails(NRCMainInput InputClass)
      {
          ServiceProcess _Service = new ServiceProcess();
          var ReqString = Newtonsoft.Json.JsonConvert.SerializeObject(InputClass);
          var result = await _Service.CommonPostAsync(URLConstants.NEWNRCAirCraft + "?AIRCRAFT_REG_NO="+ InputClass.AIRCRAFT_REG_NO + "&OUID=" + InputClass.OUID,ReqString);
          return result;
      }
Posted
Comments
Richard MacCutchan 20-Apr-23 7:53am    
I am not a Xamarin specialist, but you could try moving the line
selectAircraft.ItemsSource = aircraft;

after the end of the foreach loop.
[no name] 20-Apr-23 10:29am    
"aircraft" needs to be a property if you're going to bind to it. You don't show the definitions; or the DataContext(s).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900