Hi TechBang, Please look at this example (But this is not in MVVM pattern, for the MVVM patter follow the link which I gave at last)
First of all as per you requirement I create a design page.
<grid showgridlines="True">
<grid.columndefinitions>
<columndefinition width="200" />
<columndefinition width="400" />
</grid.columndefinitions>
<stackpanel name="SP1" grid.column="0">
<radiobutton groupname="ControlLoad" name="btncontrol"> Button Control
</radiobutton>
<radiobutton groupname="ControlLoad" name="checkcontrol">CheckBox Control
</radiobutton>
<radiobutton groupname="ControlLoad" name="textcontrol">TextBox Control
</radiobutton>
<radiobutton groupname="ControlLoad" name="dropcontrol">Dropdown Control
</radiobutton>
<Button Name="btncreate" Content="Create" Margin="10" Click="btncreate_Click"></Button>
</stackpanel>
<stackpanel name="SP2" grid.column="1">
</stackpanel>
</grid>
And second part is code behind code.
private void btncreate_Click(object sender, RoutedEventArgs e)
{
if (btncontrol.IsChecked.Value)
{
Button button = new Button();
button.Content = "New Button";
button.Margin = new Thickness(5);
SP2.Children.Add(button);
}
else if (checkcontrol.IsChecked.Value)
{
CheckBox check = new CheckBox();
check.Content = "New CheckBox";
check.Margin = new Thickness(5);
SP2.Children.Add(check);
}
else if (textcontrol.IsChecked.Value)
{
TextBox textbox = new TextBox();
textbox.Text = "New TextBox";
textbox.Margin = new Thickness(5);
SP2.Children.Add(textbox);
}
else if (dropcontrol.IsChecked.Value)
{
ComboBox combo = new ComboBox();
combo.Items.Add("Item1");
combo.Items.Add("Item2");
combo.Margin = new Thickness(5);
SP2.Children.Add(combo);
}
}
Link for MVVM Pattern is
http://stackoverflow.com/questions/4420911/get-selected-radio-button-in-a-group-wpf[
^]