I avoided to ask this question, but the ListBox’s selected index can no be set. I have read the other threads and applied the settings, but it doesn’t work.
<ListBox ItemsSource="{Binding}"
HorizontalAlignment="Right"
Name="lstReading" Height="Auto"
SelectedIndex="{Binding BookmarkSelectedIndex}">
In the something.xaml.cs, I am settings
lstReading.DataContext = IQText;
Where, IQText is an IEnumerable<dictIQ> and includes the BookmarkSelectedIndex as data element. Other data elements from IQText can be used but the listindex can’t be set. Could someone please let me know why?
Are you have
BookmarkSelectedIndexinside ofdictIQclass? So, you have oneBookmarkSelectedIndexper item, not per collection!You can create separate property
BookmarkSelectedIndexoutside ofdictIQor create class that inherited fromObservalbeCollection<dictIQ>and have additional propertyBookmarkSelectedIndex:I hope you choose best solution suitable for you