silverlight 5开发【vb版】(4)-容器
程序员文章站
2022-03-02 11:47:00
...
容器里可以放很多控件,我们可以看XAML。
<UserControl x:Class="SilverlightApplication2.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"> <Grid x:Name="LayoutRoot" Background="White"> <sdk:Label Height="40" HorizontalAlignment="Left" Margin="88,210,0,0" Name="Label1" VerticalAlignment="Top" Width="207" /> <sdk:Label Height="32" HorizontalAlignment="Left" Margin="82,247,0,0" Name="Label2" VerticalAlignment="Top" Width="214" /> <StackPanel Height="66" HorizontalAlignment="Left" Margin="68,68,0,0" Name="StackPanel1" VerticalAlignment="Top" Width="272"> <TextBox Height="25" Name="TextBox1" Width="206" DataContext="{Binding}" Text="" /> <Button Content="确定" Height="22" Name="Button1" Width="183" /> </StackPanel> </Grid>
StackPanel就是一个容器
<StackPanel Height="66" HorizontalAlignment="Left" Margin="68,68,0,0" Name="StackPanel1" VerticalAlignment="Top" Width="272">
<TextBox Height="25" Name="TextBox1" Width="206" DataContext="{Binding}" Text="" />
<Button Content="确定" Height="22" Name="Button1" Width="183" />
</StackPanel>
从上面可以看出来有2个控件在容器里,TextBox和Button
因为一个控件里可以包括多个属性,比如:
<Button Height="22" Name="Button1" Width="183">
<Button.Content>
确定
</Button.Content>
</Button>
但一个控件需要包括多个控件,必须是容器。
<UserControl x:Class="SilverlightApplication2.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"> <Grid x:Name="LayoutRoot" Background="White"> <sdk:Label Height="40" HorizontalAlignment="Left" Margin="68,153,0,0" Name="Label1" VerticalAlignment="Top" Width="207" /> <sdk:Label Height="32" HorizontalAlignment="Left" Margin="68,209,0,0" Name="Label2" VerticalAlignment="Top" Width="214" /> <StackPanel Height="66" HorizontalAlignment="Left" Margin="68,68,0,0" Name="StackPanel1" VerticalAlignment="Top" Width="272"> <TextBox Height="25" Name="TextBox1" Width="206" DataContext="{Binding}" Text="" /> <Button Height="22" Name="Button1" Width="183"> <Button.Content> 确定 </Button.Content> </Button> </StackPanel> </Grid> </UserControl>
推荐阅读
-
silverlight 5开发【vb版】(6)-鼠标滚轮事件
-
silverlight 5开发【vb版】(11)- 样式与模板
-
silverlight 5开发【vb版】(12)-数据和RIA基础(2)
-
silverlight 5开发【vb版】(7)-silverlight 5开发工具包ISO
-
silverlight 5开发【vb版】(12)-数据和RIA基础(1)
-
silverlight 5开发【vb版】(5)-鼠标左右键事件
-
silverlight 5开发【vb版】(3)-简单鼠标事件处理
-
silverlight 5开发【vb版】(4)-容器
-
silverlight 5开发(2)-hello,world第一个程序(vb.net实现)
-
silverlight 5开发(2)-hello,world第一个程序(vb.net实现)