WPF notes (2.5 Canvas)--layout

Source: Internet
Author: User

Canvas is the most accurate layout container--absolute positioning, the book authors do not recommend that the size of the control will generally change as the internal font image dynamically generated, so use the first three layouts is the best choice, in this regard, I also share the same opinion.

Canvas uses the Top/bottom property to control the height of the distance from the top/bottom, and the Left/right property to control the distance from the left/right. Interestingly, the size of the form is adjusted, the position of the second TextBlock varies, but the distance from the bottom and the right is constant, as shown in the code:

<Canvas Background="Yellow">
  <TextBlock Canvas.Left="10" Canvas.Top="20">Hello</TextBlock>
  <TextBlock Canvas.Right="10" Canvas.Bottom="20">world!</TextBlock>
</Canvas>

In addition, canvas does not automatically reduce content beyond its own scope, that is, the extra content appears outside the canvas because the default cliptobounds= is "False", and if you set cliptobounds= "True", you will crop more than the content.

Finally, using Viewbox together enables automatic layout controls to resize (see the next section).

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.