I am trying to display 8 schedule block rectangles on my grid.

Rectangle[] ScheduleRectangle;

for (i = 0; i < 8; i++)
{
ScheduleRectangle[i] = new Rectangle();
ScheduleRectangle[i].Height = 28;
ScheduleRectangle[i].Width = 576;
Grid.SetColumn(ScheduleRectangle[i], 1);
ScheduleRectangle[i].StrokeThickness = 1;
ScheduleRectangle[i].Stroke = Brushes.Black;
ScheduleRectangle[i].HorizontalAlignment = HorizontalAlignment.Left;
ScheduleRectangle[i].VerticalAlignment = VerticalAlignment.Top;
ScheduleRectangle[0].Margin = new Thickness(87, 140+(i*80), 0, 0);
MiscGrid.Children.Add(ScheduleRectangle[i]);
}

It compiles, but throws an exception. It gives an error if I try to define the array within the for loop. What's the correct way to do this? Thanks.

Sutton