I have a listbox in a Silverlight C# app which is binded to some data from a database in XAML:
<StackPanel>
<TextBlock x:Name="ItemText" Text="{Binding Name}" Foreground="White" FontSize="35" TextAlignment="Left"/>
<TextBlock x:Name="DetailsText" Text="{Binding Description}" Foreground="Gray" Margin="0,-6,0,3" />
</StackPanel>
Now in code behind file, i am trying to get the string “Name” (binded above) based on the selection user makes in the listbox.
I tried the SelectedIndex property of listbox but it only returns integer. Can anyone help me?
I think , ListBox’s ItemSource poperty is binded to some custom collection of objects
1- if you handeling selectionchanged event than you can use SelectedItem property
that means
where lstName is name of your listbox
and CustomObject is the type of object in the ItemSource property of listbox