zoukankan      html  css  js  c++  java
  • WPF布局管理之Canvas、InkCanvas (转)

    一、Canvas

    在WPF中子元素的绝对定位的布局控件

    • 其子元素使用Width、Height定义元素的宽度和高度
    • 使用Convas.Left(Convas.Right)、Convas.Top(Convas.Bottom)定义与Convas容器的相对位置
    • 如果同时存在Convas.Left和Convas.Right、Convas.Top和Convas.Bottom,则Convas.Left、Convas.Top优先生效

    例如:

     <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>

    在调整窗体大小时,LT与左、上距离保持不变;RT与右、上距离保持不变;LB与左、下距离保持不变;RB与右、下距离保持不变。使用Canvas不能简单地实现Windows应用程序中Acho的功能。

    二、InkCanvas

    在WPF中实现允许使用墨迹的控件。如:

     <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>
  • 相关阅读:
    VS2012打开项目——已停止工作
    使用copydata实现进程之间数据传递
    WPF Demo20 模板
    WPF Demo19 命令、UC
    WPF Demo18 路由事件
    WPF Demo17 数据绑定
    Spark2.3.0 报 io.netty.buffer.PooledByteBufAllocator.metric
    Impala与Hive的优缺点和异同
    Hive 报错信息及解决方法
    hive表多种存储格式的文件大小差异,无重复数据
  • 原文地址:https://www.cnblogs.com/fuchongjundream/p/3832913.html
Copyright © 2011-2022 走看看