欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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>