我是这种语言的新手。我读了这个方法 http://windowsphonegeek.com/articles/listpicker-for-wp7-in-depth 但我仍然有这个问题:
// Constructor
public MainPage()
{
InitializeComponent();
List<SampleData> dataSource = new List<SampleData>();
dataSource.Add(new SampleData() { Day = "Sunday"});
dataSource.Add(new SampleData() { Day = "Monday"});
dataSource.Add(new SampleData() { Day = "Tuesday"});
dataSource.Add(new SampleData() { Day = "Thirsday"});
dataSource.Add(new SampleData() { Day = "Wednesday"});
dataSource.Add(new SampleData() { Day = "Friday" });
dataSource.Add(new SampleData() { Day = "Saturday"});
this.listPicker.ItemsSource = dataSource;
}
public class SampleData
{
public string Day { get; set; }
}
我创建了一个列表选择器并插入了值,现在我创建了这个按钮1:
private void button1_Click(object sender, RoutedEventArgs e)
{
String s;
s=(String)listPicker.SelectedItem;
MessageBox.Show(s);
}
我没有选择日期,但有一个无效的转换错误,我不知道选择的返回值。你能帮助我吗?