Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Here is my code :
use to get "CheckMark" tag from XML file listed bel
C#
foreach (XmlNode node in DOC.SelectNodes("//CheckMarkObject"))
           {


               FbCheckMark checkmark = new FbCheckMark();


               checkmark.Name = node.SelectSingleNode("Name").InnerText;
               checkmark.Label = node.SelectSingleNode("Label").InnerText;

               if (node.SelectSingleNode("IsChecked").InnerText == "0")
               {
                   checkmark.IsChecked = false;
               }
               else
               {
                   checkmark.IsChecked = true;
               }

               listCheckMarks.Add(checkmark);

           }



now and this is the control code for generating against this tag:

for (int i = 0; i < listCheckMarks.Count; i++)
{
if (listCheckMarks[i].checkMark.Equals(checkMark))
{

CheckBox cb = new CheckBox();
TextBlock cbtextblock = new TextBlock();
cbtextblock.Text = listCheckMarks[i].Label;
cbtextblock.Height = 27;
cbtextblock.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
cbtextblock.Margin = new Thickness(12, 20, 0, 0);
cbtextblock.VerticalAlignment = System.Windows.VerticalAlignment.Top;
cb.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
cb.VerticalAlignment = System.Windows.VerticalAlignment.Top;
cb.Margin = new Thickness(150, 21, 0, 0);
cb.Height = 50;
cb.Width = 100;
cb.Name = listCheckMarks[i].Name;




LayoutRoot.Children.Add(cbtextblock);
LayoutRoot.Children.Add(cb);

}
}

now my question is that when i use "CheckMark" tag 2 time. it generate checkmark control 2 times. but it overwrite the previous control.
plzz tell me the answer what can i do for this. that the new control come after the previous one. thanks
Posted
Comments
thursunamy 30-Nov-12 9:48am    
Before you run listCheckMarks.Add(checkmark); block control previous added elements contain any element that has same tag if not continue add.If exists change the tag for example add "1" as postfix. It can solve your problem

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900