我解決了你的問題。我所做的就是將ListPicker Itemsource綁定到.xaml上,而不是放在後面的代碼上,並且完美地工作。
這是您所提供的文件中編輯的.xaml代碼:
<toolkit:ListPicker ItemsSource="{Binding LstCountry}" SelectedIndex="55" x:Name="listPickerCountrySignup" Height="72" HorizontalAlignment="Left" Margin="14,43,0,0" VerticalAlignment="Top" Width="436" FullModeHeader="Select Country" Background="White" BorderBrush="White" CacheMode="BitmapCache" >
.xaml.cs代碼
公共部分類的MainPage:的PhoneApplicationPage,INotifyPropertyChanged的 {// 構造 公衆MainPage() { InitializeComponent(); BindList(); 這個。DataContext = this; }
public class country
{
public int CountryID { get; set; }
}
public event PropertyChangedEventHandler PropertyChanged;
void NotifyPropertyChanged(String propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (null != handler)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
List<country> _lstCountry;
public List<country> LstCountry
{
get{return _lstCountry;}
set{
if(_lstCountry!=value)
{
_lstCountry = value;
NotifyPropertyChanged("LstCountry");
}
}
}
void BindList()
{
LstCountry = new List<country>();
for (int i = 0; i <= 100; i++)
{
LstCountry.Add(new country { CountryID = i });
}
}
private void button1_Click(object sender, RoutedEventArgs e)
{
listPickerCountrySignup.SelectedIndex = 15;
}
private void button2_Click(object sender, RoutedEventArgs e)
{
listPickerCountrySignup.SelectedIndex = 25;
}
private void button3_Click(object sender, RoutedEventArgs e)
{
listPickerCountrySignup.SelectedIndex = 39;
}
private void button4_Click(object sender, RoutedEventArgs e)
{
listPickerCountrySignup.SelectedIndex = 55;
}
private void button5_Click(object sender, RoutedEventArgs e)
{
listPickerCountrySignup.SelectedIndex = 75;
}
}
請將您的問題減少到最小的尺寸,但仍然存在問題。不,我不知道你的來源的大小,但鏈接到它導致我相信它不適合在這裏 - 一個好兆頭,這不是一個減少的問題。此外,沒有冒犯,但我不傾向於點擊今天和年齡的隨機鏈接... – 2012-08-11 18:20:48
@lc。它只是一個頁面,其不超過1.5 MB,因爲它包含了我用於更好地糾正問題的silverlight工具包dll。我只是上傳了示例代碼,因爲它有很多版本,並且更改了silverlight套件。我正在使用11月份的verion官方的一個 – 2012-08-11 18:25:45