2013-06-22 30 views
2
<ComboBox x:Name="c1" Margin="21,134,228,-184" BorderBrush="{x:Null}" BorderThickness="6" Background="{x:Null}" Foreground="#FFFF0017" /> 

List<String> source = new List<String>(); 

c1.ItemsSource = source; 

c1.SelectedIndex = 0; 

我可以看到項目但我不能選擇它們嗎?我不能滾動?就像當我添加比組合框的尺寸更大時,Windows Phone 8中的組合框

它應該出現滾動?我來自windows store c#,這就是它在那裏的方式。

我希望它能像普通的組合框一樣工作,點擊它就會出現一個可滾動的項目列表,您可以選擇......謝謝!

+2

嘗試這樣的: http://www.codeproject.com/Articles/129558/The-ComboBox-is-Dead-Long-Live-the-ListPicker 據我所知組合框(或控制像這樣)在WP應用程序中不推薦使用(它應該只用於小型收藏 - 例如約3項)。 –

回答

4

不建議使用組合框控件。使用ListPicker控件。

步驟:

  1. 下載NuGet包從這個鏈接:https://www.nuget.org/packages/WPtoolkit/

  2. 添加到您的XAML文件的頂部一個參考:

    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit" 
    
  3. 使用ListPicker如圖所示如下:

    <toolkit:ListPicker Height="50" ScrollViewer.VerticalScrollBarVisibility="Auto" ItemsSource="{Binding ElementName=ConverterPage, Path=Locations}" Margin="179,129,70,434" Name="cmbCurrFrom"> 
         <toolkit:ListPicker.ItemTemplate> 
          <DataTemplate> 
           <TextBlock FontSize="30" Foreground="Black" Text="{Binding Path=Location}"></TextBlock> 
          </DataTemplate> 
         </toolkit:ListPicker.ItemTemplate> 
         <toolkit:ListPicker.FullModeItemTemplate> 
          <DataTemplate> 
           <TextBlock FontSize="30" Foreground="Black" Text="{Binding Path=Location}"></TextBlock> 
          </DataTemplate> 
         </toolkit:ListPicker.FullModeItemTemplate> 
        </toolkit:ListPicker>