zoukankan      html  css  js  c++  java
  • WPF中的容器控件——DockPanel

    DockPanel  很有意思控件往四周绕着进来,顺序为上下左右中,都是单排的。逆时针的一圈一圈的转到内部,这个东西想法很好,估计实际应用基本用不着。如果平行的容器比较多的时候 应该有点用。实际用的比较多的应该是层层嵌套。(便宜了做网页设计的)。

    这个布局,还可以顺便带着,复习一下java的布局,跟这几个容器的布局也很类似。这一点 可见WPF布局是博采众长,最少flex,java都很像。

    其他的容器都用过没举例子,鉴于java我也不精通。那就来搞个例子,记录在这里防止时间一到,忘记啦,那就可惜啦。

    这里面还是有个“附加属性的问题”,细看之下DockPanel.Dock与ApplacationControlBar的Dock属性有何不同?嘿嘿,正好印证了DockPanel的本意“靠边站”。Dock=“true”不就是靠边站的意思吗?具体靠在哪边呢?请看:DockPanel.Dock="left",DockPanel.Dock="top"....。然也!细看DockPanel的属性,

    <DockPanel>

      <Button content="button1" DockPanel.Dock="top"></Button>        /*想想三个空间的Dock属性同为top怎么处理,很明显两个排起来*/

      <Button content="button2" DockPanel.Dock="top"></Button>

      <Button content="button3" DockPanel.Dock=“top” Margin=“10”></Button>/*又见margin属性意思跟StackPanel中的Margin一样,到边沿的距离*/

      <Button content="button4" DockPanel.Dock="left"></Button>

      <Button content="button5" DockPanel.Dock="Right"></Button>

      <Button content="button6" DockPanel.Dock="bottom"></Button>

      <Button content="button7"></Button>

    </DockPanel>

    看上面的布局代码,可以想见界面的top部分由三行,分别是button1、button2、button3。because DockPanel.Dock=“top”。

      左边有一列,button4。

      右边有一列,button5。

      底部有一行,button6。

           中间是,button7。

    我们可以这样想,假如恰好是5个控件那么刚好是分布在上下左右中,沾满整个界面。把界面上的button换做WrapPanel、StackPanel效果又会如何?是不是搞复杂掉啦。

    (我猜测复杂的界面就是这样设计出来的)

     提供者:www.kmuser.com

  • 相关阅读:
    liunx挂载Ios镜像文件
    liunx下删除多个目录下的相同文件
    tomcat启动报错:Unable to complete the scan for annotations for web application [] due to a StackOverflow
    lr中controller 中scenario-> rendezvous显示灰色不可用
    liunx 下在指定文件夹下搜索字符
    python运行时提示:dot not in the path
    1.4 python 类型转换函数
    js字符串拼接
    自己写的时间轴空控件
    ios禁止页面下拉
  • 原文地址:https://www.cnblogs.com/dagedan/p/2740777.html
Copyright © 2011-2022 走看看