I would like to create a form dynamically instead of using the XAML to do it.
The form reside into a tab control. Below is XAML code:
this is a XAML sample.
<TabControl>
<TabItem Header="SVRS Data" Name="tab_SVRS_Data2">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="113*" />
<ColumnDefinition Width="113*" />
<ColumnDefinition Width="55*" />
<ColumnDefinition Width="58*" />
<ColumnDefinition Width="113*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="13" />
<RowDefinition Height="24" />
<RowDefinition Height="15" />
<RowDefinition Height="24" />
<RowDefinition Height="24" />
<RowDefinition Height="24" />
<RowDefinition Height="24" />
<RowDefinition Height="5" />
<RowDefinition Height="24" />
<RowDefinition Height="24" />
<RowDefinition Height="5" />
<RowDefinition Height="24" />
<RowDefinition Height="24" />
<RowDefinition Height="24" />
<RowDefinition Height="24" />
<RowDefinition Height="5" />
<RowDefinition Height="24" />
<RowDefinition Height="24" />
<RowDefinition Height="24" />
<RowDefinition Height="5" />
<RowDefinition Height="24" />
<RowDefinition Height="5" />
<RowDefinition Height="24" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Button Name="btn_SaveSVRSDataDyn" Content="Save" Grid.Column="4" Grid.Row="1" ToolTip="Saves the changes to the SVRS data " FontWeight="Bold" Click="btn_SaveSVRSData_Click" />
<TextBox Name="SVRS_OuterEnvelopeId2" Grid.Column="0" Grid.Row="1" Style="{StaticResource InputBoxes}" Grid.ColumnSpan="2" />
<Label Content="Outer Enveloppe ID" Grid.Column="0" Grid.Row="1" Style="{StaticResource LabelsOverlay}" Grid.ColumnSpan="2" Margin="5,0" />
<TextBox Name="SVRS_LastName2" Grid.Row="3" Style="{StaticResource InputBoxes}" Grid.ColumnSpan="2" Uid="Elector"/>
<Label Content="Last Name" Grid.Row="3" Style="{StaticResource LabelsOverlay}" Grid.ColumnSpan="2" Margin="5,0"/>
<TextBox Name="SVRS_FirstName2" Grid.Row="4" Style="{StaticResource InputBoxes}" Grid.ColumnSpan="2" Uid="Elector"/>
<Label Content="First Name" Grid.Row="4" Style="{StaticResource LabelsOverlay}" Grid.ColumnSpan="2" Margin="5,0"/>
<TextBox Name="SVRS_MiddleName2" Grid.Column="2" Grid.Row="3" Style="{StaticResource InputBoxes}" Grid.ColumnSpan="3" Uid="Elector" Margin="1" />
<Label Content="Middle Name" Grid.Column="2" Grid.Row="3" Style="{StaticResource LabelsOverlay}" Grid.ColumnSpan="3" Margin="5,0"/>
<TextBox Name="SVRS_DaytimePhoneNumber2" Grid.Column="2" Grid.Row="4" Style="{StaticResource InputBoxes}" Grid.ColumnSpan="3" Uid="Elector" Margin="1" />
<Label Content="Daytime Phone" Grid.Column="2" Grid.Row="4" Style="{StaticResource LabelsOverlay}" Grid.ColumnSpan="3" Margin="5,0"/>
<ComboBox Name="SVRS_GenderTypeCode2" Grid.Row="5" Style="{StaticResource ComboBoxes}" Uid="Elector"/>
<Label Content="Gender" Grid.Row="5" Style="{StaticResource LabelsOverlay}"/>
<TextBox Name="SVRS_DOB2" Grid.Column="1" Grid.Row="5" Style="{StaticResource InputBoxes}" Uid="Elector" MaxLength="10" CharacterCasing="Upper" DataContext="{Binding}" LostFocus="SVRS_DOB_LostFocus" />
<Label Content="DOB" Grid.Column="1" Grid.Row="5" Style="{StaticResource LabelsOverlay}"/>
<TextBox Name="SVRS_EveningPhoneNumber2" Grid.Column="2" Grid.Row="5" Style="{StaticResource InputBoxes}" Grid.ColumnSpan="3" Uid="Elector" Margin="1" />
<Label Content="Evening Phone" Grid.Column="2" Grid.Row="5" Style="{StaticResource LabelsOverlay}" Grid.ColumnSpan="3" Margin="5,0"/>
<ComboBox Name="SVRS_Language2" Grid.Row="6" Style="{StaticResource ComboBoxes}" Uid="Elector"/>
<Label Content="Language" Grid.Row="6" Style="{StaticResource LabelsOverlay}"/>
<TextBox Name="SVRS_EmailAddress2" Grid.Column="1" Grid.Row="6" Style="{StaticResource InputBoxes}" Grid.ColumnSpan="4" Uid="Elector" Margin="1" />
<Label Content="email" Grid.Column="1" Grid.Row="6" Style="{StaticResource LabelsOverlay}" Grid.ColumnSpan="4" Margin="5,0"/>
</Grid>
</TabItem>
</TabControl>
If you mean that you want to generate these controls by code at runtime, then the following snippet will give you an idea: