在没有XAML的情况下绘制形状

时间:2015-09-18 16:52:49

标签: c# windows xaml

您好我正在尝试在屏幕中间绘制一个简单的矩形形状。不幸的是,我在网上找到的所有教程都告诉我如何在XAML中完成它。我找到的一个教程告诉我如何在窗体中绘制矩形

System.Drawing.Graphics graphics = this.CreateGraphics();
System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(50, 100, 150, 150);

graphics.DrawEllipse(System.Drawing.Pens.Black, rectangle);
graphics.DrawRectangle(System.Drawing.Pens.Red, rectangle);

然而,这在通用应用内部无效。对于Universal应用程序,有类似的东西吗?非常感谢你

1 个答案:

答案 0 :(得分:2)

简短回答:不,不是真的。

在Windows通用应用中,您有3个主要选择在屏幕上绘制内容:

1-您可以使用已经看过的XAML组件,create such components programmatically as wellcreate animations with them

2-您可以创建HTML/Javascript-based application

3-您可以use a XAML control as a raw canvas and draw graphics on it using DirectX/DirectWrite,但您可能需要使用C ++来进行实际绘图。