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;