温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Canvas、InkCanvas 布局(六)

发布时间:2020-06-26 19:05:37 来源:网络 阅读:1154 作者:kyirsheng 栏目:编程语言

一、Canvas
在 WPF 中子元素的绝对定位的布局控件
其子元素使用 Width、Height 定义元素的宽度和高度
使用 Convas.Left(Convas.Right)、Convas.Top(Convas.Botto
m)定义与 Convas 容器的相对位置
如果同时存在 Convas.Left 和 Convas.Right、 Convas.Top 和 Convas.
Bottom,则 Convas.Left、Convas.Top 优先生效
例如:
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" Widt
h="75">RT</Button>
4: <Button Canvas.Left="10" Canvas.Bottom="10" Height="23" Wi
dth="75">LB</Button>
5: <Button Canvas.Right="10" Canvas.Bottom="10" Height="23" W
idth="75">RB</Button>
6: </Canvas>


在调整窗体大小时,LT 与左、上距离保持不变;RT 与右、上距离保持不变;LB 与左、下距
离保持不变;RB 与右、下距离保持不变。使用 Canvas 不能简单地实现 Windows 应用程
序中 Acho 的功能。
二、InkCanvas
在 WPF 中实现允许使用墨迹的控件。如:
1: <Window x:Class="WPFLayoutDemo.InkCanvasDemo"
2: xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presen
tation"
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" Ink
Canvas.Top="10"
10: Source="Logo2.png"/>
11: </InkCanvas>
12: </Window>

Canvas、InkCanvas 布局(六)其他的功能与 Canvas 相近。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI