title: how to add 2 list in nested listview in xamarin forms
body: <p>I am new to xamarin froms. i need to bind 2 list in one listview.i am getting dataset from webservice(Total 3 datatables). I Have tried implementing nested listview i.e listview inside listview. i am giving them the name but when i am trying to access the inner listview code behind is not picking up(I know the reason tho). i have researched but i didnt got any relevant article to go through. here is what i have implemented. Basically, i am trying to build a survey/test app.</p>
  
  <pre><code>IEnumerable&lt;StartParticularSurvey&gt; _questionList;
  IEnumerable&lt;StartParticularSurvey&gt; _answerList;
  
  var response = e.Result.ToString();
  var result = StartParticularSurvey.FromJson(response);
              if (result[0][0].bit_HasError == true)
              {
                  Device.BeginInvokeOnMainThread(() =&gt;
                  {
                      Navigation.PushAsync(new UserSurveyList());
                      DisplayAlert("Alert!", result[0][0].vchar_ErrorMsg, "Ok");
                  });
              }
              else
              {
                  Device.BeginInvokeOnMainThread(() =&gt;
                  {
                      var questionDataset = result[1][0]; //trying to get Table2 in questionDataset
                      var answerDataset = result[2][0]; //trying to get Table3 in answerDataset
                      _questionList = questionDataset as IEnumerable&lt;StartParticularSurvey&gt;;
                      _answerList = answerDataset as IEnumerable&lt;StartParticularSurvey&gt;;
                      lvSurveyQuestion.ItemsSource = _questionList;
                      lvSurveyAnswer.itemSource = _answerList; //Here is where the .cs is not picking up and i know why.
                  });
              }  
  </code></pre>
  
  <p>xaml:</p>
  
  <pre><code>&lt;ListView x:Name="lvSurveyQuestion"&gt;
                  &lt;ListView.ItemTemplate&gt;
                      &lt;DataTemplate&gt;
                          &lt;ViewCell&gt;
                              &lt;StackLayout&gt;
                                  &lt;Label Text="{binding data here}"/&gt;
                                  &lt;ListView x:Name="lvSurveyAnswer"&gt;
                                      &lt;ListView.ItemTemplate&gt;
                                          &lt;DataTemplate&gt;
                                              &lt;ViewCell&gt;
                                                  &lt;StackLayout&gt;
                                                      &lt;Label Text="{binding data here}"/&gt;
                                                      &lt;Label Text="{binding data here}"/&gt;
                                                  &lt;/StackLayout&gt;
                                              &lt;/ViewCell&gt;
                                          &lt;/DataTemplate&gt;
                                      &lt;/ListView.ItemTemplate&gt;
                                  &lt;/ListView&gt;
                              &lt;/StackLayout&gt;
                          &lt;/ViewCell&gt;
                      &lt;/DataTemplate&gt;
                  &lt;/ListView.ItemTemplate&gt;
              &lt;/ListView&gt;
  </code></pre>
  
  <p>Model:</p>
  
  <pre><code>namespace IVSConnectMobile.Model
  {
      public partial class StartParticularSurvey
      {
          [JsonProperty("bit_HasError", NullValueHandling = NullValueHandling.Ignore)]
          public bool? bit_HasError { get; set; }
  
          [JsonProperty("vchar_ErrorMsg", NullValueHandling = NullValueHandling.Ignore)]
          public string vchar_ErrorMsg { get; set; }
  
          [JsonProperty("int_SurveyQuestionID", NullValueHandling = NullValueHandling.Ignore)]
          public long? int_SurveyQuestionID { get; set; }
  
          [JsonProperty("vchar_Description", NullValueHandling = NullValueHandling.Ignore)]
          public string vchar_Description { get; set; }
  
          [JsonProperty("vchar_Instruction")]
          public string vchar_Instruction { get; set; }
  
          [JsonProperty("int_AnswerType", NullValueHandling = NullValueHandling.Ignore)]
          public long? int_AnswerType { get; set; }
  
          [JsonProperty("vchar_Option", NullValueHandling = NullValueHandling.Ignore)]
          public string vchar_Option { get; set; }
      }
  
      public partial class StartParticularSurvey
      {
          public static List&lt;List&lt;StartParticularSurvey&gt;&gt; FromJson(string json) =&gt; JsonConvert.DeserializeObject&lt;List&lt;List&lt;StartParticularSurvey&gt;&gt;&gt;(json, IVSConnectMobile.Model.Converter.Settings);
      }
  
      public static class Serialize
      {
          public static string ToJson(this List&lt;List&lt;StartParticularSurvey&gt;&gt; self) =&gt; JsonConvert.SerializeObject(self, IVSConnectMobile.Model.Converter.Settings);
      }
  
      internal static class Converter
      {
          public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
          {
              MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
              DateParseHandling = DateParseHandling.None,
              Converters = {
                  new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
              },
          };
      }
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/8XosF.png" rel="nofollow noreferrer">This Image is the result that i am getting after serializing the data</a></p>
  
  <p>Any other suggestion are welcome</p>
  
  <p><a href="https://i.stack.imgur.com/hKIcH.png" rel="nofollow noreferrer">This is a sample UI</a></p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I created 2 Model </p>
  
  <pre><code> public class SurveyAnswerList
      {
          public int int_AnswerType { get; set; }
          public string vchar_Option { get; set; }
      }
  
  public class SurveyQuestionList : List&lt;SurveyAnswerList&gt;
      {
          public string vchar_Description { get; set; }
  
          public SurveyQuestionList(string description)
          {
              vchar_Description = description;
          }
      }
  </code></pre>
  
  <p>In code behind</p>
  
  <pre><code>public List&lt;Model.SurveyQuestionList&gt; _list { get; set; }
  
  _list = new List&lt;Model.SurveyQuestionList&gt;();
                  Device.BeginInvokeOnMainThread(() =&gt;
                  {
                      for (int i = 0; i &lt; result[1].Count; i++)
                      {
                          for (int j = 0; j &lt; result[2].Count; j++)
                          {
                              if (result[1][i].int_SurveyQuestionID == result[2][j].int_SurveyQuestionID)
                              {
                                  _list = new List&lt;SurveyQuestionList&gt;{
                                      new SurveyQuestionList(result[1][i].vchar_Description){
                                          new SurveyAnswerList{ vchar_Option = result[2][j].vchar_Option }
                                      }
                                  };
                              }
  
                          }
                      }
                      lvSurvey.ItemsSource = _list;
                  });
  </code></pre>
  
  <p>XAML:</p>
  
  <pre><code>             &lt;ListView x:Name="lvSurvey"
                        IsGroupingEnabled="True"
                        GroupDisplayBinding="{Binding vchar_Description}"&gt;
                  &lt;ListView.ItemTemplate&gt;
                      &lt;DataTemplate&gt;
                          &lt;ViewCell&gt;
                              &lt;StackLayout&gt;
                                  &lt;Label Text="{Binding vchar_Option}"/&gt;
                              &lt;/StackLayout&gt;
                          &lt;/ViewCell&gt;
                      &lt;/DataTemplate&gt;
                  &lt;/ListView.ItemTemplate&gt;
              &lt;/ListView&gt;
  </code></pre>