KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am trying to bind a list of string values to a listbox so that their values are listed line by line. Right now I use this: <ListBox Margin="20" ItemsSource="{Binding Path=PersonNames}"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding Path=Id}"></TextBlock> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> But I don't know what I am supposed to put into the textblock, instead of Id , since they are all string values, not custom classes. Also it complains not having to find the PersonNames when I have it inside MainPage, as MainPage.PersonNames. I set the data context to: DataContext="{Binding RelativeSource={RelativeSource Self}}" I am doing it wrong?
Tags (comma-separated)
Save Edits
Cancel