首先 你要确认 你有安装Toolkit,然后添加引用,在工程中添加引用。点击Project–Add Reference–.Net选项卡,下拉,找到Microsoft.Phone.Controls.Toolkit,双击添加
第一种xaml里面添加
<toolkit:ListPicker Header="Categories">
<toolkit:ListPickerItem Content="Johnny" />
<toolkit:ListPickerItem Content="Tommy" />
<toolkit:ListPickerItem Content="Alumi" />
</toolkit:ListPicker>
CS里面不用写代码
第二种 XAML里面添加
<toolkit:ListPicker Header="Default" Height="229" Name="defaultPicker" Width="414" />
CS里面
this.defaultPicker.ItemsSource = new List<String>() { "London", "China", "Mexico" };
第三种颜色选择控件 XAML
<toolkit:ListPicker Header="Full ListPicker" Height="217" Name="listPicker1" Width="410" ItemsSource="{Binding}">
<toolkit:ListPicker.FullModeItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Rectangle Fill="{Binding}" Width="40" Height="40" Margin="10, 10, 10, 10"/>
<TextBlock Text="{Binding}" VerticalAlignment="Center"/>
</StackPanel>
</DataTemplate>
</toolkit:ListPicker.FullModeItemTemplate>
<toolkit:ListPicker.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Rectangle Fill="{Binding}" Width="40" Height="40" Margin="10, 10, 10, 10"/>
<TextBlock Text="{Binding}" VerticalAlignment="Center"/>
</StackPanel>
</DataTemplate>
</toolkit:ListPicker.ItemTemplate>
</toolkit:ListPicker>
CS里面添加
static readonly string[] AccentColors = { "magenta", "purple", "teal", "lime", "brown", "pink", "orange", "blue", "red", "green" };
this.listPicker1.DataContext = AccentColors;
显示效果如下
ItemCountThreshold属性 设定 当项目大于几个的时候使用新的页面呈现 如上图所示
SelectedIndex属性 设定 项目的索引