Learn about Windows Phone7 Development (13. Eight ListBox controls)

Source: Internet
Author: User

The ListView control is removed from the Phone7, which is the only ListBox control, but the control is very powerful and fully capable of achieving ListView functionality. Because this control is also equivalent to a container, you can combine multiple controls by ListItem to get a list of different functions.

Xaml:

<ListBox Grid.Row="1" Height="567" HorizontalAlignment="Left" Margin="12,53,0,0" Name="listBox1" VerticalAlignment="Top" Width="460">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <Image Source="{Binding ImgSource}" Width="130" Height="130"/>
                        <TextBlock Text="{Binding Name}" Foreground="Yellow" FontSize="25"/>
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
//{Binding ImgSource}:动态绑定图片资源。
//{Binding Name}:动态绑定text文字。

Source:

ImageList item1 = new ImageList();
    item1.ImgSource = new BitmapImage(new Uri("Images/Chrysanthemum.jpg", UriKind.Relative));
    item1.Name = "Chrysanthemum.jpg";
    list.Add(item1);

     ImageList item2 = new ImageList();
     item2.ImgSource = new BitmapImage(new Uri("Images/Desert.jpg", UriKind.Relative));
     item2.Name = "Desert.jpg";
     list.Add(item2);

    ImageList item3 = new ImageList();
    item3.ImgSource = new BitmapImage(new Uri("Images/Hydrangeas.jpg", UriKind.Relative));
    item3.Name = "Hydrangeas.jpg";
    list.Add(item3);

    listBox1.ItemsSource = list;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.