private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { Point clickpoint = e.GetPosition(this.MyPanel); DrawingVisual dv = new DrawingVisual(); this.drawRect(dv, clickpoint); MyPanel.AddChild(dv); }
private void Window_Loaded(object sender, RoutedEventArgs e) { DrawingVisual dv = new DrawingVisual(); DrawingContext dc = dv.RenderOpen(); Brush brush = Brushes.LightGreen; Pen pen = new Pen(Brushes.SteelBlue, 3); dc.DrawRectangle(brush, pen, new Rect(new Point(10, 10), new Size(50, 25))); dc.DrawEllipse(brush, pen, new Point(10, 60), 50, 25); dc.DrawLine(pen, new Point(10, 100), new Point(80, 120)); dc.Close(); MyPanel.AddChild(dv); }