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>