Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Here is my code :
use to get "CheckMark" tag from XML file listed bel
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 29-Nov-12 23:42pm
Comments
thursunamy at 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)



Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 30 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100