Canvas and inkcanvas for WPF layout management)

Source: Internet
Author: User
I. Canvas

Layout controls for absolute positioning of child elements in WPF

  • Its child elements use width and height to define the width and height of the element.
  • Use convas. Left (convas. Right) and convas. Top (convas. Bottom) to define the relative position of the convas container.
  • If both convas. Left and convas. Right, convas. Top, and convas. Bottom exist, convas. Left and convas. Top take effect first.

For example:

 <Canvas>  <Button Canvas.Left="10" Canvas.Top="10" Height="23" Width="75">LT</Button> <Button Canvas.Right="10" Canvas.Top="10" Height="23" Width="75">RT</Button> <Button Canvas.Left="10" Canvas.Bottom="10" Height="23" Width="75">LB</Button> <Button Canvas.Right="10" Canvas.Bottom="10" Height="23" Width="75">RB</Button></Canvas>

When the form size is adjusted, the distance between LT and left and top remains unchanged; the distance between RT and right and top remains unchanged; and the distance between lb and left and bottom remains unchanged; the distance between Rb and right and bottom remains unchanged. Using canvas cannot simply implement the Acho function in Windows applications.

Ii. inkcanvas

You can use ink widgets in WPF. For example:

 <Window x:Class="WPFLayoutDemo.InkCanvasDemo"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  Title="InkCanvasDemo" Height="200" Width="300"> <InkCanvas>     <InkCanvas.DefaultDrawingAttributes>            <DrawingAttributes Color="Red" />        </InkCanvas.DefaultDrawingAttributes>    </InkCanvas> </Window>

 

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.