2012-06-19 68 views

回答

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; } 
    } 


} 
+0

通過使用listpicker我不能get.when點擊一個按鈕需要顯示1到30個數字。通過使用listpicker我需要點擊,然後只顯示所有items.please告訴我哪個控制是適合的,當點擊按鈕需要顯示1到30個數字相同頁面.. – WP7

+0

嘗試將按鈕點擊前的可見性設置爲摺疊狀態,單擊時將其設置爲可見。我無法理解你的問題,並且你能否展示一個圖像示例來知道你實際需要什麼。 –

+0

請參閱圖片... – WP7

1

你可以利用ListPicker for WP7,而不是爲WP7組合框的。

而要在彈出窗口中顯示ListPicker,請將ListPicker放在MessagePrompt中。

+0

本地內容通過使用listpicker再次,我需要點擊該控件來顯示所有items.but我需要顯示當點擊一個按鈕放置在同一頁面的項目...哪個控件我需要用來顯示項目時點擊同一頁面上的按鈕? – WP7

+0

然後用一個MessagePrompt和放置在其中的ListBox。並且你可以設置列表框的來源爲1到30的數字 – nkchandra

+0

任何示例請讓我知道.. – WP7

相關問題