Windows Phone StackPanel 布局示例
生活随笔
收集整理的這篇文章主要介紹了
Windows Phone StackPanel 布局示例
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
效果
?
?
XAML
01: <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> 02: <StackPanel Height="443" HorizontalAlignment="Left" Margin="20,45,0,0" Name="stackPanel1" 03: VerticalAlignment="Top" Width="442"> 04: <TextBlock FontSize="64" FontWeight="Bold" Name="textBlock1" Text="1" 05: Style="{StaticResource PhoneTextAccentStyle}" TextAlignment="Center" /> 06: <TextBlock FontSize="64" FontWeight="Bold" Name="textBlock3" Text="3" 07: Style="{StaticResource PhoneTextAccentStyle}" TextAlignment="Center" /> 08: <TextBlock FontSize="64" FontWeight="Bold" Name="textBlock5" Text="5" 09: Style="{StaticResource PhoneTextAccentStyle}" TextAlignment="Center" /> 10: </StackPanel> 11: <Button Content="Change" Height="72" HorizontalAlignment="Left" Margin="20,494,0,0" Name="btnChange" VerticalAlignment="Top" Width="160" Click="btnChange_Click" /> 12: <Button Content="Insert2" Height="72" HorizontalAlignment="Left" Margin="186,494,0,0" Name="btnInset2" VerticalAlignment="Top" Width="160" Click="btnInset2_Click" /> 13: </Grid> 14: 01: private void btnChange_Click(object sender, RoutedEventArgs e) 02: { 03: //調(diào)換排列方向 04: if (stackPanel1.Orientation == System.Windows.Controls.Orientation.Horizontal) 05: stackPanel1.Orientation = System.Windows.Controls.Orientation.Vertical; 06: else 07: stackPanel1.Orientation = System.Windows.Controls.Orientation.Horizontal; 08: } 09: 10: private void btnInset2_Click(object sender, RoutedEventArgs e) 11: { 12: 13: //創(chuàng)建一個(gè)TextBLock控件顯示數(shù)字2 14: TextBlock textBlock2 = new TextBlock(); 15: textBlock2.Text = "2"; ; 16: textBlock2.Style = textBlock1.Style; 17: textBlock2.FontSize = textBlock1.FontSize; 18: textBlock2.TextAlignment = textBlock1.TextAlignment; 19: textBlock2.FontWeight = textBlock1.FontWeight; 20: 21: //將數(shù)字2插入到Stackpanel的子元素集合中 22: stackPanel1.Children.Insert(1, textBlock2); 23: 24: }轉(zhuǎn)載于:https://www.cnblogs.com/finehappy/archive/2011/05/28/2060842.html
總結(jié)
以上是生活随笔為你收集整理的Windows Phone StackPanel 布局示例的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Office Word 2007下管理参
- 下一篇: windows API函数copyfil