Msdn Teaching Short Film WPF 2 (Drawing Graphics)

Source: Internet
Author: User
Drawing

We know that all images inherit from the shape class. Generally, canvas, ellipse, and path are commonly used)

For example, we want to draw a smiling face like this:

You can write the following in XAML:CodeTo complete

Here, the X: Name = "myellipse" setting can be used to modify its attributes. The background code is as follows:

Converts its width to 200 pixels.

We can also draw a line and use XAML to represent

<Line X1 = "50" Y1 = "200" X2 = "200" y2 = "50" stroke = "green" strokethickness = "3"/>

Stroke is the color of the fill line, strokethickness is the width of the line, x1, x2, Y1, Y2, which is the coordinate.

Use background code to write

Line line = new line ();
Line. X1 = 50;
Line. X2 = 200;
Line. Y1 = 200;
Line. y2 = 50;
Line. Stroke = brushes. Black;
Line. strokethickness = 3;

It must be displayed in the container. For example, if this line is in the grid, the grid name is grid1, And the last line is added to the grid.

Grid1.children. Add (line );

:

The same is true for an elliptical image:

In XAML:

<Ellipse Height = "52" margin = "76,0, 77,41 "name =" ellipse1 "stroke =" black "verticalignment =" bottom "strokethickness =" 6 "fill =" red "/>

The background code is similar to an underscore. Here, an ellipse object is created.

You can also draw a rectangle ).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.