您好,登錄后才能下訂單哦!
水平對齊:
- <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
- <Grid.RowDefinitions>
- <RowDefinition></RowDefinition>
- <RowDefinition></RowDefinition>
- <RowDefinition></RowDefinition>
- <RowDefinition></RowDefinition>
- </Grid.RowDefinitions>
- <Button Content="Left左部對齊" Height="80" Width="220" HorizontalAlignment="Left"></Button>
- <Button Grid.Row="1" Content="Right右部對齊" Width="220" Height="80" HorizontalAlignment="Right"></Button>
- <Button Grid.Row="2" Width="220" Height="80" Content="Center劇中對齊" HorizontalAlignment="Center"></Button>
- <Button Grid.Row="30" Height="80" HorizontalAlignment="Stretch" Content="Stretch拉伸對齊"></Button>
- </Grid>
注意:Stretch:元素以垂直填充的方式進行布局
HorizontalAlignment要使用Stretch值,就不能設置元素的Width屬性,否則Stretch值將不會起作用。
垂直對齊:
- <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
- <Grid.RowDefinitions>
- <RowDefinition></RowDefinition>
- <RowDefinition></RowDefinition>
- <RowDefinition></RowDefinition>
- <RowDefinition></RowDefinition>
- </Grid.RowDefinitions>
- <Button Content="Top頂端對其" Height="80" Width="220" VerticalAlignment="Top"></Button>
- <Button Grid.Row="1" Content="Center居中對齊" Width="220" Height="80" VerticalAlignment="Center"></Button>
- <Button Grid.Row="2" Width="220" Height="80" Content="Bottom底部對齊" VerticalAlignment="Bottom"></Button>
- <Button Grid.Row="30" Width="220" VerticalAlignment="Stretch" Content="Stretch拉伸對齊"></Button>
- </Grid>
注意:Stretch:元素以水平方向填充父元素的布局空間
VerticalAlignment在使用Stretch值時,就不能設置元素的Height屬性,否則Stretch將不會起作用。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。