C#開發(fā)Windows UWP系列之布局面板RelativePanel
RelativePanel是在Windows 10 UWP程序中引入的一種新的布局面板,它是通過附加屬性設(shè)置元素間的位置關(guān)系來對實現(xiàn)布局的。一個簡單的示例如下:
<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>布局的效果如下:

它支持如下幾種位置關(guān)系:
和其它元素相鄰:
LeftOf
RightOf
Above
Below
和其他元素邊緣對齊:
AlignBottomWith
AlignLeftWith
AlignTopWith
AlignRightWith
和其它元素中心對齊:
AlignHorizontalCenterWith
AlignVerticalCenterWith
和Panel邊緣對齊:
AlignBottomWithPanel
AlignLeftWithPanel
AlignRightWithPanel
AlignTopWithPanel
和Panel中心對齊:
AlignHorizontalCenterWithPanel
AlignVerticalCenterWithPanel
試用了一下,常用的對齊方式都有了,基本上各種復(fù)雜的布局都能輕易的實現(xiàn)。唯一的缺點是,這種布局方式和和其它元素耦合的,里面的元素不像其它的面板那樣可以隨意刪除。不過也非常強(qiáng)大了,比起之前WinRt下的那些布局面板要方便多了。
到此這篇關(guān)于UWP布局面板RelativePanel的文章就介紹到這了。希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
C#/VB.NET實現(xiàn)在PDF文檔中插入,替換或刪除圖片
這篇文章主要為大家詳細(xì)介紹了如何使用 Spire.PDF for .NET 通過程序在 PDF 文檔中插入、替換或刪除圖片,感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2023-12-12
WinForm中comboBox控件數(shù)據(jù)綁定實現(xiàn)方法
這篇文章主要介紹了WinForm中comboBox控件數(shù)據(jù)綁定實現(xiàn)方法,結(jié)合實例形式分析了WinForm實現(xiàn)comboBox控件數(shù)據(jù)綁定的常用方法與相關(guān)操作技巧,需要的朋友可以參考下2017-05-05

