views:

59

answers:

4

Hello

I'm currently trying to add a regular line shape to both the canvas and a custom object. I'm not getting an error, but the line is not being added to the canvas

The relevant bit of code is below

lh = new LineHolder();
Line lnx = new Line();

lnx.StrokeThickness = 1;

MainCan.Children.Add(lnx);

lh.MainLiner = lnx;
lstLH.Add(lh);

lstLH is a list of LineHolder objects.

Has anyone ever encountered something like this before? It does not like being added to both entities it seems.

Thanks ~Steve

A: 

I it possible that you need to specify the Top and Left properties of the child your adding?

Micah
I'm not sure I understand, what do you mean by the Op?
sorry...I left out half of my sentence...try again.
Micah
A: 

yup - I just tried that, same result - it's as if adding it to the list removes it from the canvas, without throwing any sort of error.

A: 

I think Micah is on the right track - except the most properties on the Line you need to set are X1, Y1, X2, Y2 - namely the coordinates of each end of the line. If this doesn't work, I'd suggest setting the Fill property as well.

I don't think adding the line to your own object is the problem here.

George Sealy
A: 

I tried setting the X and Y coordinates, and got the same result. I did put the coordinate matching in a second function (it does it twice) and call it with a timer after the lines are added to the canvas, and that works for some unknown reason.