Bind Dictionary with list in viewmodel to checkboxes
<p>How do you properly bind a Dictionary and it's values per key to checkboxes?
I can display them in the HTTPGET but binding the selected values again to HTTPPOST doesn't seem to work.</p>

<p>viewmodel</p>

<pre><code>public class EditViewModel
{
    public Foo Foo { get; set; }
    public Dictionary&lt;Bar, List&lt;BarVersionEditVM&gt;&gt; Matrix { get; set; }
}

public class BarVersionEditVM
{
    public int ID { get; set; }
    public string Name { get; set; }
    public string Version { get; set; }
    public bool IsSupported { get; set; }
}
</code></pre>

<p>view:</p>

<pre><code>&lt;form asp-action="Edit"&gt;
&lt;div class="row"&gt;
 @foreach (var kvp in Model.Matrix.OrderByDescending(x =&gt; x.Key.Name))
 {
   &lt;div class="col-md-2 col-lg-2"&gt;
     &lt;fieldset&gt;
         &lt;legend&gt;@kvp.Key.Name&lt;/legend&gt;
        @foreach (var version in kvp.Value)
        {
          &lt;div&gt;
           &lt;input type="checkbox" id="@version.ID" value="@version.IsSupported" name="@version.Name" @(version.IsSupported ? "checked=\"checked\"" : "") /&gt;
               &lt;label&gt;@version.Version:&lt;/label&gt;
         &lt;/div&gt;
        }
    &lt;/fieldset&gt;
  &lt;/div&gt;
  }
  &lt;/div&gt;
&lt;input type="hidden" asp-for="@Model.Foo.ID" /&gt;
&lt;input type="submit" value="Save" class="btn btn-default" /&gt;
&lt;/form&gt;
</code></pre>

<p>In the View I tried also to rewrite with foreach and using Html helpers, but without success:</p>

<p>@Html.CheckBoxFor(model => model.Matrix[kvpair.Key][i].IsSupported)</p>

<p>controller:</p>

<pre><code>[HttpPost]
[ValidateAntiForgeryToken]
public async Task&lt;IActionResult&gt; Edit(EditViewModel vm) {
 // vm is there but Matrix  are null.
// and only the ID of Foo property is filled in.
}
</code></pre>

<p>any suggestions?</p>