private void StageInitialize(int width, int height, int length) { Width = width; Height = height; BlocksLength = length; BlocksWidth = Width / BlocksLength; BlocksHeight = Height / BlocksLength; Blocks = new Model.Block[BlocksHeight, BlocksWidth]; Stage = new View.Block[BlocksHeight, BlocksWidth]; for (int y = 0; y < BlocksHeight; y++) { for (int x = 0; x < BlocksWidth; x++) { Blocks[y, x] = new Block(); Stage[y, x] = new View.Block(BlocksLength - 2); Rectangle rectangle = new Rectangle { Margin = new Thickness(1) }; Binding brushBinding = new Binding("Brush") { Source = Stage[y, x] }; rectangle.SetBinding(Rectangle.FillProperty, brushBinding); Binding lengthBinding = new Binding("Length") { Source = Stage[y, x] }; rectangle.SetBinding(Rectangle.HeightProperty, lengthBinding); rectangle.SetBinding(Rectangle.WidthProperty, lengthBinding); StageView.Add(rectangle); } } }