Skip to main content
Home Forums Silverlight Programming Silverlight Controls and Silverlight Toolkit Value does not fall within expected range exception [:(]
6 replies. Latest Post by varshavmane on July 2, 2009.
(0)
varshavmane
Contributor
6723 points
1,580 Posts
07-02-2009 6:09 AM |
Hi all,
Below is the Method which work fine for the first time but when I call this method for second time it give me runtime exception saying 'Value does not fall within expected range exception' on line
cInner.Children.Add(b);
Can someone please tell me where I am doing mistake ?
Here is the Code:
{
}
b.Name =
b.BorderThickness =
b.Width = 100;
b.Height = 40;
t.Text = item;
t.TextWrapping =
t.VerticalAlignment =
b.Child = t;
l.X1 = param[0];
l.Y1 = param[1];
l.X2 = param[2];
l.Y2 = param[3];
};
l.StrokeThickness = 1;
cInner.Children.Add(l);
Thanks in advance.
HarshBar...
Star
9908 points
1,719 Posts
07-02-2009 6:15 AM |
From this code i am not able to figure out what is actual cause but the error mentioned by you can occur when you are trying to add a framework element which is aprt of a collection to some other collection.
07-02-2009 6:27 AM |
Thanks for the reply. The thing is that I have to create a rectangle with text inside and once first element is created then I have to join the first and the secong rectangle.
So I am using Border, Textblock and Line to join them. This is I have to do till I have items in my List.
Can you please tell me how do I add it again and again ?
vincracker
3116 points
522 Posts
07-02-2009 6:39 AM |
Hi Varsha,
I think you might have problem with the name. First you add element then it works fine but second time it fails, what it means we only have to concentrate on the points which changes for second pass. And I mostly forgot to change the name when adding the control again which end up with "value doesn't fall withing expected range". I strongly recommend you to double check it.
varshavmane:Border b = new Border(); b.Name = "brGraphNode_" + item;
b.Name = "brGraphNode_" + item;
(if you still have problem then let me know otherwise mark reply as answer.)
07-02-2009 6:44 AM |
Thank you so much
I was knowing this and thats the reason I have set
but I forgot that in my list, item names are repeating Like Untreated is 2 times in the list.
Many Thanks ....
07-02-2009 6:59 AM |
I told you Varsha we developer make silly mistakes when come to implement complex scnarios or we just overlook things. Happy Coding.
07-02-2009 7:04 AM |
Yes very true...
By the way its Varsha not Versha