A damn at Han's Windows Phone Book notes (5: ruler -- canvas)

Source: Internet
Author: User

Canvas features:

It is significantly different from grid and stackpanel: it has no dynamic layout. After the child element is put, it is fixed.

Therefore, you do not need to set alignment and margin for the child elements of the canvas, nor can you adapt the transformation between landscape and portrait.

If you use canvas for the layout, either landscape or portrait is required.

The default length and width of the canvas are 0, and the part that exceeds the canvas boundary is displayed. Remember to set the length and width for the canvas.

If the child element Running out of the canvas is clicked, the canvas still receives the event.

The Default background color of canvas is not transparent, but null. The background color is null and transparent looks the same. The difference is that transparent can respond to clicks, but null does not work (except when a child element is clicked ).

 

Draw line

 

Tips for making a button easier to hit

If the background behind the button also receives a click, it is easy to point an error. In this case, you can add padding to make the button easier to hit.

 

Ishittestvisible

If this attribute is false, no gesture is returned. It is visually opaque and "tactile" is transparent.

 

Slider Control

Its largechange attribute indicates the minimum amount of changes to be dragged at a time. Smallchange does not have any effect.

Set the vertical alignment attribute of the slider to center. If it is the default value of strech, touching somewhere else in the parent container will also change the slider.

 

The getposition function locates the touch position.

You can obtain the location information by using the event parameters when you tap or drag.

Set the function to capture drag and tap events:

<Canvas mousemove = "interactivecanvas_mousetapordrag"
Mouseleftbuttondown = "interactivecanvas_mousetapordrag">

Use the getposition function to process events:

Void interactivecanvas_mousetapordrag (Object sender, mouseeventargs E)
{
// Get the finger position relative to the landscape-oriented page
Double X = E. getposition (this). X;

The relativeto parameter of the getposition function refers to the position of the control relative to which it is not required to be the parent control.

 

InCodeUsing static Resources

Staticresource in XAML, in the form of C # code: application. Current. Resources ["name"], for example:

This. layoutroot. Background = application. Current. Resources ["phonechromebrush"] as brush;

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.