我需要用GDI图形在WPF中的表单上绘制一个圆。 我不能用windows窗体来做到这一点,所以我添加了一个使用。 我无法使用WPF的Elipse控件。我的老师告诉我这样做。在WPF上用GDI图形绘制圆形
这是我的代码:
public void MakeLogo()
{
System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Green);
System.Drawing.Graphics formGraphics = this.CreateGraphics();
formGraphics.FillEllipse(myBrush, new System.Drawing.Rectangle(0, 0, 200, 300));
myBrush.Dispose();
formGraphics.Dispose();
}
这是错误:
MainWindow' does not contain a definition for 'CreateGraphics' and no extension method 'CreateGraphics' accepting a first argument of type 'MainWindow' could be found (are you missing a using directive or an assembly reference?)
“我需要用GDI图形绘制的窗体上圆WPF”。是什么原因?为什么你不能使用WPF Ellipse控件? – Clemens
这是我的任务的要求之一。我不知道为什么我的老师想要这个。 @Clemens – Gigitex
我猜你误解了这个任务,你应该在WinForms中这样做。 – LarsTech