如何在wp7中单击按钮时显示项目列表?

时间:2012-06-19 05:56:10

标签: windows-phone-7 windows-phone-7.1

我在一个页面中放置了一个按钮。当点击那个需要在组合框中显示1到30个数字时,只在该页面中显示一个弹出窗口。请告诉我如何实现这个目标?

编辑:

see the image

2 个答案:

答案 0 :(得分:1)

你可以使用ListPicker for WP7而不是WP7的ComboBox。

要在弹出窗口中显示ListPicker,请将ListPicker放在MessagePrompt中。

答案 1 :(得分:1)

我已经用设计编辑了答案,在项目中添加了一个图像作为本地内容

  <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        <Button Content="Button" Height="82" HorizontalAlignment="Left" Margin="44,59,0,0" Name="button1" VerticalAlignment="Top" Width="376" Click="button1_Click" />
        <ListBox ItemsSource="{Binding item}" Width="376" Name="lst" Margin="56,128,48,76" Background="White">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Border BorderThickness="1" DataContext="{Binding}"  BorderBrush="Black">
                        <StackPanel Width="376" Orientation="Vertical" Height="Auto">
                            <Image Margin="200,20,-75,5"  Height="50" Width="50" Source="{Binding img}"></Image>
                            <TextBlock Margin="-200,-15,90,3"  Height="50" Width="50" Name="text" Text="{Binding text}" Foreground="Black"></TextBlock>
                        </StackPanel>
                    </Border>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid>
</Grid>

 lst.visibility = visibility.collapsed;

private void button1_Click(object sender, RoutedEventArgs e)
    {

        lst.visibility = visibility.visible;
        List<Itemss> data = new List<Itemss>();
        for (int i = 0; i < 30; i++)
        {
        Itemss item = new Itemss();


            item.text = i.ToString();



            item.img = "/images.jpg";

            data.Add(item);

        }

        lst.ItemsSource = data;
       }



    public class Itemss
    {
        public string text { get; set; }
        public string img { get; set; }
    }


}