Windows Phone (25) Canvas Element B

Source: Internet
Author: User

Zindex

This is also an additional attribute that indicates the display sequence of child elements in the children set of the canvas. By default, the elements in the canvas are the child elements that follow the canvas to overwrite the child elements, therefore, we can use this additional property to change the display property. zindex is actually a virtual Z axis, extending out of the screen in the positive direction. The greater the zindex value, the more outward it is, the smaller the value, the easier it is to be overwritten. Therefore, if you want to set a sub-element display, you can set zindex to greater than limit. The default value of zindex is 0;

Touch Processing

The following example shows how to change the deformation object of the rendertransform attribute. elements can be moved on the screen, or the elements in the canvas can be moved by setting the left and top additional attributes in the code;

First, draw three ellipse elements in canva, and set the demonstration to red, green, and blue. In addition, when you move an ellipse object, its zindex will be at the top layer, that is, set the zindex value of the moving object to be greater than the other two.

Some code of XAML:

<! -- Contentpanel-place other content here --> <grid X: Name = "contentpanel" grid. row = "1" margin = "12, 0, 12, 0"> <canvas name = "cav"> <ellipse canvas. left = "50" canvas. top = "50" width = "100" Height = "100" fill = "red"> </ellipse> <ellipse canvas. left = "150" canvas. top = "150" width = "100" Height = "100" fill = "green"> </ellipse> <ellipse canvas. left = "250" canvas. top = "250" width = "100" Height = "100" fill = "blue"> </ellipse> </canvas> </GRID>

The XAML code is relatively simple. The two additional attributes are set to the relative position, and the width and height are equal to the circle to fill in three different colors. Here we rewrite the onmanipulationstarted and onmanipulationdelta methods in the onmanipulationstarted Method E. manipulationcontainer = CAV;

Partially hide code

Protected override void onmanipulationstarted (manipulationstartedeventargs e) {// container e that obtains the Defined coordinates. manipulationcontainer = CAV; base. onmanipulationstarted (E);} int I = 0; protected override void onmanipulationdelta (manipulationdeltaeventargs e) {// obtain the element uielement element = E. originalsource as uielement; // get the modification point translation = E. deltamanipulation. translation; // set the new position canvas. setleft (element, canvas. getleft (element) + translation. x); canvas. settop (element, canvas. gettop (element) + translation. y); canvas. setzindex (element, I ++); E. handled = true; base. onmanipulationdelta (E );}

No moving Effect

 

The above shows that a new method is canvas. getleft (element), which is used to obtain the left value of the child element in the canvas. Similarly, canvas. gettop (element) and canvas. setzindex (element, I ++); place the moving element on the outermost layer

Let's take a look at the mobile effect.

 

Another one:

 

May 1 is over. Start working.

Related Article

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.