1
C#을 사용하여 Windows Metro 스타일 응용 프로그램의 ListBox 컨트롤에 텍스트 파일 이름을 바인딩하려면 어떻게합니까?텍스트 파일을 XAML ListBox 컨트롤에 바인딩
또는 :
은 어떻게 XAML의 ListBox 컨트롤에 사전()를 결합 하는가?
C#을 사용하여 Windows Metro 스타일 응용 프로그램의 ListBox 컨트롤에 텍스트 파일 이름을 바인딩하려면 어떻게합니까?텍스트 파일을 XAML ListBox 컨트롤에 바인딩
또는 :
은 어떻게 XAML의 ListBox 컨트롤에 사전()를 결합 하는가?
문서화, 검색 및 질문을 통해 끝없는 시간을 읽은 것 같았습니다. 나는 이것을 스스로 알아낼 수 있었다.
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;
}
다음
내가 내 상황에 필요한대로 작동 코드