title: Bind ExpandoObject to MudBlazor Form Controls
body: <p>I am trying to accomplish Functionality similar to Angular FormBuilder, where we dynamically add Controls and Validations.</p>
  <p>In MudBlazor or Blazor in general, we have to use C# Model to bind with Controls.</p>
  <p>So I decided to use ExpandoObject with dynamically added Properties to bind with MudBlazor controls with <code>OnInitialized</code> Method as below</p>
  <pre><code>    dynamic FormModel = new ExpandoObject();
      protected override void OnInitialized()
      {
          FormModel.FirstName = null;
          FormModel.LastName = null;
          FormModel.Age = 0;
  
          //Or with Dictionary
  
         ((IDictionary&lt;string, object&gt;)FormModel).Add(&quot;FirstName&quot;, &quot;&quot;);
          ((IDictionary&lt;string, object&gt;)FormModel).Add(&quot;LastName&quot;, &quot;&quot;);
          ((IDictionary&lt;string, object&gt;)FormModel).Add(&quot;Age&quot;, 0);
      }
  </code></pre>
  <p>and in HTML using MudBlazor Textbox</p>
  <pre><code>&lt;MudTextField Label=&quot;First name&quot; @bind-Value=FormModel.FirstName /&gt;
  </code></pre>
  <p>While compiling with first approach it gives the following error</p>
  <blockquote>
  <p>Cannot use a lambda expression as an argument to a dynamically
  dispatched operation without first casting it to a delegate or
  expression tree type.</p>
  </blockquote>
  <p>While running with second &quot;object&quot; approach it gives error at runtime, when value is changed/entered.</p>
  <blockquote>
  <p>Conversion to type System.Object not implemented</p>
  </blockquote>