Hello Everyone,
I am trying to build dynamic UI based on xml entities. Till now I was just reading values from xml & binding them in XAML file like below
my xml <abc>True</abc>
my XAML <CheckBox Content="test1" Margin="20,10,0,0" IsChecked="{Binding XPath=abc}" />
<CheckBox Content="test2" Margin="20,30,0,0" IsChecked="{Binding XPath=def}" />
Now I am trying to modify myxaml irrespective of number of entities in my xml (it can be any number of checkboxes & other controls in xml)
myxml now <Control Checkbox description="abc" value=true ></Control> (please give suggestions for better format)
<Control Checkbox description="def" value=false ></Control>
<Control Checkbox description="ghi" value=false></Control> checkbox is type of control since I can have other controls also
I can create checkbox using System.Windows.Controls.CheckBox chckbox = new CheckBox();
but I am not sure how my XAML entity will return how many controls are there inside one particular node in xml
I was doing google, I found below code to add controls dynamically.
Is it possible to get list of checkbox from xml in XAML & calling addcheckbox in that particular group or stackpanel that number of times ?
<CheckBox Name="addcheck" Click="addCheckbox">Add Another</CheckBox>
public void addCheckbox(object sender, RoutedEventArgs e)
{
// System.Windows.Controls.Button newBtn = new Button();
System.Windows.Controls.CheckBox chckbox = new CheckBox();
chckbox.Content="test";
Thickness margin = chckbox.Margin;
margin.Top = 5;
chckbox.Margin = margin;
splMain.Children.Add(chckbox);
}
THanks
I am trying to build dynamic UI based on xml entities. Till now I was just reading values from xml & binding them in XAML file like below
my xml <abc>True</abc>
<def>True</def>
my XAML <CheckBox Content="test1" Margin="20,10,0,0" IsChecked="{Binding XPath=abc}" />
<CheckBox Content="test2" Margin="20,30,0,0" IsChecked="{Binding XPath=def}" />
Now I am trying to modify myxaml irrespective of number of entities in my xml (it can be any number of checkboxes & other controls in xml)
myxml now <Control Checkbox description="abc" value=true ></Control> (please give suggestions for better format)
<Control Checkbox description="def" value=false ></Control>
<Control Checkbox description="ghi" value=false></Control> checkbox is type of control since I can have other controls also
I can create checkbox using System.Windows.Controls.CheckBox chckbox = new CheckBox();
but I am not sure how my XAML entity will return how many controls are there inside one particular node in xml
I was doing google, I found below code to add controls dynamically.
Is it possible to get list of checkbox from xml in XAML & calling addcheckbox in that particular group or stackpanel that number of times ?
<CheckBox Name="addcheck" Click="addCheckbox">Add Another</CheckBox>
public void addCheckbox(object sender, RoutedEventArgs e)
{
// System.Windows.Controls.Button newBtn = new Button();
System.Windows.Controls.CheckBox chckbox = new CheckBox();
chckbox.Content="test";
Thickness margin = chckbox.Margin;
margin.Top = 5;
chckbox.Margin = margin;
splMain.Children.Add(chckbox);
}
THanks