So here is my problem: I am looking to find the binded string named "id" from the selected element in my listbox. Here is my .xaml:
<ListBox Name="lstView">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid/>
<TextBlock Text="{Binding id}"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
And my c# which sends data to fill the listbox:
var articles = root.data.movies.Select(m => new Article { Name = m.title, ImagePath = m.medium_cover_image, Year = m.year.ToString() }).ToList();
foreach (Article s in articles)
{
this.lstView.Items.Add(new Article {id = m.id.ToString()});
}
I have tried various different scenarios, but nothing has worked yet :/
Actually I found a way simpler way to get this working (thanks for your help anyway):
Article selectedArticle = lstView.SelectedItem as Article;
And then to get any string binded to that element you call:
selectedArticle.nameofthebindedstring
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments