Silverlight: Value does not fall within the expected range exception

前端 未结 4 666
臣服心动
臣服心动 2020-12-19 09:35

I am getting \"Value does not fall within the expected range exception\" when adding children to stack panel. This happens even when myStackPanel.Children.Count = 0 just be

4条回答
  •  太阳男子
    2020-12-19 10:31

    This error can be caused when there are two elements being added with the same name. In your case, are there any duplicate lDoc.Name values? If so, you could add an extra unique identifier. For example:

    int id = 0; //outside foreach loop
    
    myTextborder.Name = lDoc.Name + id.ToString();
    id++;
    

提交回复
热议问题