title: Generate C# code from XAML
body: <p>In my current project I have make UI dynamically in C#. This can be a very boring and difficult task. So is there a tool that can generate C# code of XAML UI markup?</p>
  
  <p>For instance, I have grid here in XAML</p>
  
  <pre><code>    &lt;Grid  &gt;
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition  /&gt;
              &lt;RowDefinition  /&gt;
          &lt;/Grid.RowDefinitions&gt;
      &lt;/Grid&gt;
  </code></pre>
  
  <p>and I want it to be converted it to</p>
  
  <pre><code> Grid grdTextField = new Grid();
   RowDefinition firstrow = new RowDefinition();
   RowDefinition secondrow = new RowDefinition();
  </code></pre>
  
  <p>This is simple case but for little bit complex UI it will be difficult to make from Code behind.</p>
  
  <p>EDIT:-</p>
  
  <p>Actually i am getting a Json that determine how my a large Grid created. it has six to seven types of complicated views and these views can come multiple times (so has to put some logic at run time). so 
  overall i have to make a grid on the basis of this json.</p>
  
  <p>EDIT 2 :- this is part of json on the basis of this i have to make a UI</p>
  
  <pre><code> "decimal_variables": [
              {
                  "id": 1, 
                  "name": "Time Taken", 
                  "var_type": 2, 
                  "is_required": true, 
                  "default": null, 
                  "max_value": "10000.000000", 
                  "min_value": "0.000000", 
                  "unit": "sec", 
                  "score_dependency": 2
              }, 
              {
                  "id": 2, 
                  "name": "Number of moves", 
                  "var_type": 2, 
                  "is_required": true, 
                  "default": null, 
                  "max_value": "1000.000000", 
                  "min_value": "0.000000", 
                  "unit": "moves", 
                  "score_dependency": 2
              }, 
              {
                  "id": 3, 
                  "name": "Number of hints used", 
                  "var_type": 2, 
                  "is_required": true, 
                  "default": null, 
                  "max_value": "100.000000", 
                  "min_value": "0.000000", 
                  "unit": "hints", 
                  "score_dependency": 2
              }
          ], 
          "choice_variables": [
              {
                  "choices": [
                      {
                          "id": 1, 
                          "name": "Easy", 
                          "value": "1.000000"
                      }, 
                      {
                          "id": 2, 
                          "name": "Medium", 
                          "value": "2.000000"
                      }, 
                      {
                          "id": 3, 
                          "name": "Tough", 
                          "value": "3.000000"
                      }
                  ], 
                  "id": 1, 
                  "name": "Difficulty level", 
                  "var_type": 1, 
                  "is_required": true, 
                  "default": null, 
                  "score_dependency": 3
              }
          ], 
          "boolean_variables": [
              {
                  "id": 1, 
                  "name": "Is Hint Allowed", 
                  "var_type": 1, 
                  "default": true, 
                  "score_dependency": 3
              }
          ], 
          "text_variables": [
              {
                  "id": 1, 
                  "name": "Instructions to student", 
                  "var_type": 1, 
                  "is_required": false, 
                  "default": "1. Carefully do the assignment.\r\n2. Time is key in assignment score, so make sure not to waste the time.", 
                  "max_length": 1000, 
                  "score_dependency": 3
              }
          ], 
          "file_variables": [
              {
                  "default": "media/variable-files/supermegafunbits-1024x1024.png", 
                  "id": 1, 
                  "name": "Image", 
                  "var_type": 1, 
                  "is_required": false, 
                  "file_type": "image/jpeg,image/png", 
                  "score_dependency": 3
              }
          ], 
  </code></pre>
  
  <p>now in for file  variable i have to make a ui that contain a Image Control , Button to browse Image , header TextBlock, and info TextBlock (It may be complicated).so i am looking for a tool that in which if i make a UI from xaml can be converted to C# code lot of time and unnecessary coding can be saved.</p>