日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

[Winodows Phone 7控件详解]容器控件

發布時間:2023/12/18 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 [Winodows Phone 7控件详解]容器控件 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

在Windows Phone7中存在著多個容器控件,這些控件主要是用來界面的布局設置,以及包容多個控件時的布局設置。

一.Grid控件:主要用于界面的布局,這個和web page里的很相似,可以通過網格布置規劃界面,也可以嵌套使用。

<Grid x:Name="LayoutRoot" Background="#DCDCDC" Width="400" Height="300" ShowGridLines="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="250" />
<ColumnDefinition Width="150" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="2*" />
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Margin="10" FontWeight="Bold" Text="Contoso Corporation" HorizontalAlignment="Center" VerticalAlignment="Center" />
<Grid x:Name="FormLayoutGrid" Grid.Row="1" Grid.Column="0" ShowGridLines="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="First Name" Margin="10" HorizontalAlignment="Left" VerticalAlignment="Center" />
<TextBox Grid.Row="0" Grid.Column="1" Margin="10" />
<TextBlock Grid.Row="1" Grid.Column="0" Text="Last Name" Margin="10" HorizontalAlignment="Left" VerticalAlignment="Center" />
<TextBox Grid.Row="1" Grid.Column="1" Margin="10" />
<TextBlock Grid.Row="2" Grid.Column="0" Text="Address" Margin="10" HorizontalAlignment="Left" VerticalAlignment="Center" />
<TextBox Grid.Row="2" Grid.Column="1" Margin="10" />

</Grid>
</Grid>

?

二.Canvas控件? 容器、布局控件,主要是用絕對坐標來定位子控件。對于游戲開發來說用處很大。

<Canvas x:Name="C1" Grid.Row="2">
<CheckBox x:Name="CheckBox3" Content="CheckBox3" Canvas.Top="50" Canvas.Left="100" Canvas.ZIndex="1" />
</Canvas>

也可以使用代碼來控制

Canvas.SetLeft();
Canvas.SetTop();
Canvas.SetZIndex();//控制子控件在Z軸上的順序。

?

三.StackPanel控件容器、布局控件,主要用來多個子控件的縱向、橫向的布局控制。

<StackPanel x:Name="stackPanel1" Margin="20" Orientation="Vertical" >
<Rectangle Fill="Red" Width="50" Height="50" Margin="5" />
<Rectangle Fill="Blue" Width="50" Height="50" Margin="5" />
<Rectangle Fill="Green" Width="50" Height="50" Margin="5" />
<Rectangle Fill="Purple" Width="50" Height="50" Margin="5" />
</StackPanel>

可以使用下面的方法向上面的StackPanel中動態插入一個Rectangle

private void button1_Click(object sender, RoutedEventArgs e)
{
Rectangle rect = new Rectangle() { Fill = new SolidColorBrush(Colors.Yellow),Width=50,Height=50};
stackPanel1.Children.Insert(2, rect);
}

四.Border控件: 用于包容一個控件并為其繪制邊框,并且通過參數設置可以產生多種不同的邊框效果。(不太應該算為容器控件,但是又覺得放在別的類里又不是很合適。Jake Lin 和李振都這么分,我采納了這個觀點)

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,12">
<Border Background="Coral" Width="300" Height="40" Padding="10" CornerRadius="20">
<TextBlock FontSize="16">Text Surrounded by a Border</TextBlock>
</Border>
<Border x:Name="b1" Width="200" Height="200" Background="Gold" BorderBrush="Aquamarine" BorderThickness="10, 5, 20, 40" Margin="119,346,137,49" CornerRadius="25, 200, 10, 15" >
<TextBox Height="67" Name="textBox1" Text="Test Border" Background="Gold" Foreground="White" BorderBrush="Gold" Width="170" VerticalAlignment="Bottom"/>
</Border>
</Grid>

BorderThickness:邊框寬度,設置不同的值使四個邊產生不同的寬度。

CornerRadius:邊角半徑,設置不同的值四個邊角產生不同的弧度。

五.PopUp控件:嚴格來講這個不應該算作容器控件,但是它可以把包含在其中的控件顯示在當前頁的最前面,可以被打開和關閉??梢杂脕碇谱髯远x的MessageBox、WaitingBox等。

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,36,132">
<Image Source="Images/1.jpg" Height="426" HorizontalAlignment="Left" Margin="25,25,0,0" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="386" />
<!-- 這個容器可以被打開和關閉 -->
<Popup IsOpen="True" HorizontalAlignment="Left" Margin="92,106,0,0" Name="popup1" VerticalAlignment="Top" Height="250" Width="250" >
<Canvas Width="250" Height="250" Background="Red" VerticalAlignment="Center" HorizontalAlignment="Center">
<TextBlock Margin="30,120,0,0" Text="我在當前頁面的上層"/>
</Canvas>
</Popup>
</Grid>
<Button Content="打開" Grid.Row="1" Height="72" HorizontalAlignment="Left" Margin="64,523,0,0" Name="btnOpen" VerticalAlignment="Top" Width="160" Click="btnOpen_Click" />
<Button Content="關閉" Height="72" HorizontalAlignment="Left" Margin="230,523,0,0" Name="btnClose" VerticalAlignment="Top" Width="160" Grid.Row="1" Click="btnClose_Click" />
</Grid>

六.ScrollView:? 滾動查看器控件,也算是一個容器控件,它可以用來拖動顯示其所包含的控件的內容。

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Canvas>
<!-- A large TextBlock. -->
<!-- A large TextBlock. -->
<TextBlock Canvas.Top="60" Canvas.Left="-50" Width="400" TextWrapping="Wrap"
Text="I am the very model of a modern Major-General, I've information vegetable, animal, and mineral, I know the kings of England, and I quote the fights historical, From Marathon to Waterloo, in order categorical; I'm very well acquainted, too, with matters mathematical, I understand equations, both the simple and quadratical, About binomial theorem I'm teeming with a lot o' news, With many cheerful facts about the square of the hypotenuse." Margin="78,0,78,201" />

<!-- The same large TextBlock, wrapped in a ScrollViewer. -->
<!-- It can be scrolled in either direction, since VerticalScrollBarVisibility -->
<!-- has a default value of Visible. -->

<ScrollViewer BorderBrush="Green" BorderThickness="5" Height="200" Width="300" HorizontalScrollBarVisibility="Auto" Canvas.Top="400" Canvas.Left="80">
<TextBlock Width="300" TextWrapping="Wrap"
Text="I am the very model of a modern Major-General, I've information vegetable, animal, and mineral, I know the kings of England, and I quote the fights historical, From Marathon to Waterloo, in order categorical; I'm very well acquainted, too, with matters mathematical, I understand equations, both the simple and quadratical, About binomial theorem I'm teeming with a lot o' news, With many cheerful facts about the square of the hypotenuse." />
</ScrollViewer>
</Canvas>
</Grid>

?

轉載于:https://www.cnblogs.com/DebugLZQ/archive/2012/03/28/2422391.html

總結

以上是生活随笔為你收集整理的[Winodows Phone 7控件详解]容器控件的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。