0

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

编辑:

看图片

4

2 回答 2

1

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

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

于 2012-06-19T06:12:45.437 回答
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; }
    }


}
于 2012-06-19T06:18:31.030 回答