Combo box in windows phone 8

早过忘川 提交于 2019-12-24 03:00:38

问题


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

I can see the items but I can't select them? and I can't scroll??? like when I add more than the size of the combo box,

it should appear a scroll? I'm coming from windows store c# and that is the way it is over there.

I want it to make it work just as a regular combobox, you click on it and it will appear a scrollable list of items that you can select... Thanks!


回答1:


It is not recommended to use combobox control. Use the ListPicker Control.

Steps :

  1. Download the nuget package from this link: https://www.nuget.org/packages/WPtoolkit/

  2. Add a reference to the top of your xaml file :

    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    
  3. Use ListPicker as shown below :

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


来源:https://stackoverflow.com/questions/17256075/combo-box-in-windows-phone-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!