2
私には図面があり、これをキャンバスに追加して表示するにはどうすればいいですか?キャンバスにDrawingVisualを表示
DrawingVisual drawingVisual = new DrawingVisual();
// Retrieve the DrawingContext in order to create new drawing content.
DrawingContext drawingContext = drawingVisual.RenderOpen();
// Create a rectangle and draw it in the DrawingContext.
Rect rect = new Rect(new System.Windows.Point(0, 0), new System.Windows.Size(100, 100));
drawingContext.DrawRectangle(System.Windows.Media.Brushes.Aqua, (System.Windows.Media.Pen)null, rect);
// Persist the drawing content.
drawingContext.Close();
これをキャンバスに追加するにはどうすればよいですか?キャンバスがあるとします。
Canvas canvas = null;
canvas.Children.Add(drawingVisual); //Doesnt work as UIElement expected.
私のdrawingVisualをキャンバスに追加するにはどうすればよいですか?
TIA。