我有一个文件,其中第一行是电话,第二行是日期。 我读取文件并将内容添加到列表框中,所有内容都在不同的行中。 现在我改变了列表框以包含2个文本框。阅读文本文件并添加到列表框WP7
<ListBox Name="listBox1" ItemsSource="{Binding}">
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Phone}" FontSize="32"/>
<TextBlock Text="{Binding MyDate}" FontSize="16"/>
</StackPanel>
</DataTemplate>
如何绑定从文件中的数据? 谢谢
这是通过使用我如何读取文件 (StreamReader的读者=新的StreamReader(FILESTREAM)) { 做 { mPhone = reader.ReadLine(); MyDate = reader.ReadLine(); this.listBox1.Items.Add(mPhone); this.listBox1.Items.Add(MyDate); } while(!reader.EndOfStream); – 2012-03-11 15:55:20
如何使用列表数据= //负荷 –
2012-03-11 15:56:39
我能做到这一点,但列表为空 '代码' 使用(StreamReader的读者=新的StreamReader(FILESTREAM)){ 做 { mPhone = reader.ReadLine (); MyDate = reader.ReadLine(); list.Add(new PhoneDate(mPhone,MyDate)); } while(!reader.EndOfStream); listBox1.ItemsSource = list; } – 2012-03-11 17:19:03