WPF and Silverlight Learning Notes (ix): WPF layout management canvas, InkCanvas

Source: Internet
Author: User
Tags xmlns silverlight

First, Canvas

Layout controls for absolute positioning of neutron elements in WPF

Its child elements define the width and height of the element using width and height

Use Convas.left (convas.right), Convas.top (Convas.bottom) to define the relative position of the Convas container

If Convas.left and Convas.right, Convas.top and Convas.bottom are present at the same time, Convas.left, Convas.top takes precedence

For example:

1: <Canvas>
2:   <Button  Canvas.Left="10" Canvas.Top="10"  Height="23" Width="75">LT</Button>
3:   <Button Canvas.Right="10"  Canvas.Top="10" Height="23"  Width="75">RT</Button>
4:   <Button  Canvas.Left="10" Canvas.Bottom="10"  Height="23" Width="75">LB</Button>
5:   <Button Canvas.Right="10"  Canvas.Bottom="10" Height="23"  Width="75">RB</Button>
6:  </Canvas>

When the form is resized, Lt stays the same as the left and the top distance, the RT stays the same as the right and the top, and the LB and the left and the lower distance remain unchanged, and RB is kept unchanged from the right and the lower distance. Using canvas is not a simple way to implement Acho functionality in Windows applications.

Second, InkCanvas

Implements controls that allow ink to be used in WPF. Such as:

1:  <Window x:Class="WPFLayoutDemo.InkCanvasDemo"
2:     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation& quot;
3:    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4:   Title="InkCanvasDemo" Height="200"  Width="300">
5:   <InkCanvas>
6:      <InkCanvas.DefaultDrawingAttributes>
7:        <DrawingAttributes Color="Red" />
8:      </InkCanvas.DefaultDrawingAttributes>
9:     <Image  Width="155" Height="155"  InkCanvas.Left="10" InkCanvas.Top="10"
10:         Source="Logo2.png"/>
11:    </InkCanvas>
12: </Window>

Other functions are similar to canvas.

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.