积极答复者
关于LIstPicker的疑惑

问题
答案
-
你好,
你可以尝试下面的代码:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> <toolkit:ListPicker Height="100" HorizontalAlignment="Left" Margin="10,10,0,0" Name="listPicker1" VerticalAlignment="Top" Width="200" /> <TextBox Height="72" HorizontalAlignment="Left" Margin="6,203,0,0" Name="textBox1" Text="" VerticalAlignment="Top" Width="200" TextChanged="textBox1_TextChanged" /> </Grid>
public partial class MainPage : PhoneApplicationPage { // Constructor private List<string> strList; public MainPage() { InitializeComponent(); strList = new List<string>() { "AAA", "BBB" }; listPicker1.ItemsSource = strList; } private void textBox1_TextChanged(object sender, TextChangedEventArgs e) { int i = -1; foreach (string str in strList) { i++; if (str.Equals(textBox1.Text)) { listPicker1.SelectedIndex = i; break; } } } }
- 已标记为答案 ZeptoLee 2012年4月1日 1:33
全部回复
-
你好,
你可以尝试下面的代码:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> <toolkit:ListPicker Height="100" HorizontalAlignment="Left" Margin="10,10,0,0" Name="listPicker1" VerticalAlignment="Top" Width="200" /> <TextBox Height="72" HorizontalAlignment="Left" Margin="6,203,0,0" Name="textBox1" Text="" VerticalAlignment="Top" Width="200" TextChanged="textBox1_TextChanged" /> </Grid>
public partial class MainPage : PhoneApplicationPage { // Constructor private List<string> strList; public MainPage() { InitializeComponent(); strList = new List<string>() { "AAA", "BBB" }; listPicker1.ItemsSource = strList; } private void textBox1_TextChanged(object sender, TextChangedEventArgs e) { int i = -1; foreach (string str in strList) { i++; if (str.Equals(textBox1.Text)) { listPicker1.SelectedIndex = i; break; } } } }
- 已标记为答案 ZeptoLee 2012年4月1日 1:33