Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hello CodeProject!

I'm learning and learning WPF and now I have digitalised my DVD collection and wanted to list them up in my ListBox. Clicking on them should give me the details of the dvd (master-detail-view).
Now my question is: How can I retreive the data bound to the selected ListBoxItem in Code-Behind? I think I have to use the SelectionChangedEvent, but how do I access the data and not the ListBoxItem?

Thanks!
Posted

1 solution

OK, I found the solution myself:
I use e.AddedItems[0] and cast it.

C#
private void MixControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
   //MessageBox.Show(e.AddedItems[0].ToString());
   Mix mix = (Mix)e.AddedItems[0];
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900