title: Dynamically generate UI Components using Array of Structures in C#
body: <p>I am c++ developer and from last week i started working on C# and WPF. I have a very simple query about using structures in my code. I have a label and button in my xaml class which should be dynamically generated. I had developed in c++ as follows:</p>
  
  <pre><code>typedef struct 
  {
       String ChannelName;
       bool available;
  } Voltage_Channel;
  
  Voltage_Channel *m_voltageChannels;
  
  Voltage_Channel redhookChannels[6] = {
    {"", false},
    {"VDD_IO_AUD", true},
    {"VDD_CODEC_AUD", true},
    {"VDD_DAL_AUD", true},
    {"VDD_DPD_AUD", true},
    {"VDD_PLL_AUD", true},    
  };
  
  m_voltageChannels = redhookChannels;
  
  int cnt = 0; 
  int MAX_ADC =6;
  
  while(cnt &lt; MAX_ADC)
  {
      m_labelChannel[cnt] = new Label(m_voltageChannels[cnt].ChannelName); //Generates labels based on count
      m_setButton[cnt] = new TextButton("Set"); //generates Buttons based on Count
      m_setButton[cnt]-&gt;addButtonListener(this); // Event for the Button
  
      if(m_voltageChannels[cnt].available)
      {
          addAndMakeVisible(m_labelChannel[cnt]); //Displays if channel is available
          addAndMakeVisible(m_setButton[cnt]);
      }
  }  
  </code></pre>
  
  <p>This generates the label and button 6 times and if channel is available then displays it.</p>
  
  <p>I have the following in my <strong>Xaml</strong> File:</p>
  
  <pre><code>&lt;Label Grid.Column="0" Content="{Binding VoltageLabel}" Name="VoltageLabel" /&gt;
  &lt;Button Grid.Column="1" Content="Set" Command="{Binding Path=SetButtonCommand}" Name="VoltageSetbtn" /&gt;
  </code></pre>
  
  <p><strong>Label and Button Property:</strong></p>
  
  <pre><code>string voltageLabel;
  public string VoltageLabel
  {
          get { return voltageLabel; }
          set
          {
              voltageLabel = value;
              OnPropertyChanged("VoltageLabel");
          }
  }
  
      // Event for Set Button Click
      private ICommand mSetCommand;
      public ICommand SetButtonCommand
      {
          get
          {
              if (mSetCommand == null)
                  mSetCommand = new DelegateCommand(new Action(SetCommandExecuted), new Func&lt;bool&gt;(SetCommandCanExecute));
  
              return mSetCommand;
          }
          set
          {
              mSetCommand = value;
          }
      }
  
      public bool SetCommandCanExecute()
      {
          return true;
      }
  
      public void SetCommandExecuted()
      {
          // Body of the method
      }
  </code></pre>
  
  <p>Is it possible to dynamically generate these controls using structures, looking at how I had done it in my C+ application??? </p>
  
  <p>Please help</p>