M. Levin
M. Levin

Reputation: 163

Drawing a shape without XAML

Hi I am trying to draw a simple shape of rectangle in a middle of my screen. Unfortunately all the tutorials I found online tells me how to do it in XAML. The one tutorial I found tells me how to draw rectangle in a windows form

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);

however this does not work inside Universal app. Is there an analog of something like this for Universal app? Thank you very much

Upvotes: 2

Views: 683

Answers (1)

yms
yms

Reputation: 10418

Short answer: No, not really.

In Windows Universal Apps you have 3 main choices to draw something on the screen:

1- You can use XAML components as you have seen already, you can create such components programmatically as well and create animations with them.

2- You can create an HTML/Javascript-based application

3- You can use a XAML control as a raw canvas and draw graphics on it using DirectX/DirectWrite, but you may need to use C++ for doing the actual drawing.

Upvotes: 2

Related Questions