2012-09-14 64 views

回答

0

在閱讀文檔,搜索和提問之後似乎是無盡的時間;我設法弄清楚了自己。

下面是工作只是因爲我需要它在我的處境代碼:

XAML:

<ListBox Name="NotesList"> 
        <ListBox.ItemTemplate> 
         <DataTemplate> 
          <TextBlock Text="{Binding Filename}" /> 
         </DataTemplate> 
        </ListBox.ItemTemplate> 
       </ListBox> 

代碼隱藏:

public class NoteView 
    { 
     public string Filename { get; set; } 
     public string Contents { get; set; } 
    } 

    /// <summary> 
    /// Invoked when this page is about to be displayed in a Frame. 
    /// </summary> 
    /// <param name="e">Event data that describes how this page was reached. The Parameter 
    /// property is typically used to configure the page.</param> 
    protected override void OnNavigatedTo(NavigationEventArgs e) 
    { 
     var noteList = new ObservableCollection<NoteView>(); 

     for (int i = 0; i < 10; i++) 
     { 
      noteList.Add(new NoteView { Filename = "Sample note " + i }); 
     } 

     NotesList.ItemsSource = noteList; 
    }