我正在学习WPF。例如我想画圆。我可以这样:
private const ushort _operatorRadius = 50;
public MainWindow()
{
var _canvas = new Canvas();
var _operatorEllipse = new Ellipse();
SolidColorBrush mySolidColorBrush = new SolidColorBrush();
// Describes the brush's color using RGB values.
// Each value has a range of 0-255.
mySolidColorBrush.Color = Color.FromArgb(255, 255, 255, 0);
_operatorEllipse.Fill = mySolidColorBrush;
_operatorEllipse.StrokeThickness = 1;
_operatorEllipse.Stroke = Brushes.Black;
// Set the width and height of the Ellipse.
_operatorEllipse.Width = _operatorRadius;
_operatorEllipse.Height = _operatorRadius;
_canvas.Children.Add(curOperElips);
this.Content = _canvas;
}
但是 this.Content = _canvas; 将覆盖窗口的内容,然后我不能使用可视化编辑器和 MainWindow.xaml。如何将它们结合起来?