zoukankan      html  css  js  c++  java
  • Windows UWP开发系列 – RelativePanel

    RelativePanel是在Windows 10 UWP程序中引入的一种新的布局面板,它是通过附加属性设置元素间的位置关系来对实现布局的。一个简单的示例如下:

    <RelativePanel>
        <TextBox x:Name="textBox1" Text="textbox" Margin="5"/>
        <Button x:Name="blueButton" Margin="5" Background="LightBlue" Content="ButtonRight" RelativePanel.RightOf="textBox1"/>
        <Button x:Name="orangeButton" Margin="5" Background="Orange" Content="ButtonBelow" RelativePanel.RightOf="textBox1" RelativePanel.Below="blueButton"/>
    </RelativePanel>

    布局的效果如下:

            

    它支持如下几种位置关系:

    和其它元素相邻:

    • LeftOf
    • RightOf
    • Above
    • Below

    和其他元素边缘对齐:

    • AlignBottomWith
    • AlignLeftWith
    • AlignTopWith
    • AlignRightWith

    和其它元素中心对齐:

    • AlignHorizontalCenterWith
    • AlignVerticalCenterWith

    和Panel边缘对齐:

    • AlignBottomWithPanel
    • AlignLeftWithPanel
    • AlignRightWithPanel
    • AlignTopWithPanel

    和Panel中心对齐:

    • AlignHorizontalCenterWithPanel
    • AlignVerticalCenterWithPanel

    试用了一下,常用的对齐方式都有了,基本上各种复杂的布局都能轻易的实现。唯一的缺点是,这种布局方式和和其它元素耦合的,里面的元素不像其它的面板那样可以随意删除。不过也非常强大了,比起之前WinRt下的那些布局面板要方便多了。

  • 相关阅读:
    ACM进阶
    hdu 2018 母牛的故事
    hdu 2084 数塔
    动态规划算法
    hdu 1003 Max sum
    hihocoder 1037 数字三角形
    UDP和TCP的区别(转)
    JS简单的图片左右滚动
    C# MD5加密的方法+一般处理程序使用Session+后台Json序列化
    CSS DIV 独占一行,清除左右两边的浮动
  • 原文地址:https://www.cnblogs.com/TianFang/p/4886246.html
Copyright © 2011-2022 走看看