Reputation: 13620
I'm trying to create my own graph control, but I'm having some problems with the x-lines.
I've created a new control and added it to a empty WP7 project. The control has a StackPanel
with the name Canvas
and Height
and Width
set to 400.
Just to get started i written some code to get a look:
double yStepping = Canvas.Height/5;
double y = 0;
// generate x lines
for (int k = 0; k < 3; k++)
{
y += 10;
Line l = new Line()
{
Stroke = new SolidColorBrush(Colors.White),
StrokeThickness = 2,
X1 = 10,
Y1 = y,
X2 = 100,
Y2 = y
};
Canvas.Children.Add(l);
}
I would think this creates evenly spaced lines but it does not. for each line the spacing grows. Why is that?
Upvotes: 1
Views: 74
Reputation: 18118
You can use a Snoop for WPF equivelent for Silverlight e.g. Silverlight Spy to examine the visual tree and see which element(s) increase the width & height vs the inner control or even if that control has the wrong settings due to an unexpected binding.
Upvotes: 0
Reputation: 171236
The stack panel stacks your lines. Each line has a height of at least two because of its stroke thickness. In addition, the Y-value of each line adds to its height (more precisely: to its bounding box from which the height is derived).
Upvotes: 2