private void buttonRectangle_Click(object sender, RoutedEventArgs e) { ShapeRectangle rectangle = new ShapeRectangle(this.mainCanvas); rectangle.mainCanvas = this.mainCanvas; mainCanvas.Children.Add(rectangle.rect); mainCanvas.Children.Add(rectangle); }