Tuesday, December 31, 2013

How to sort items of a list by name within his index?

I've order my items by name in a list but i have a problem selecting using the SelectedIndex the item is not the same as selected



for (int i = 0; i < storageList.GetFileNames().Length; i++)
{

filesbyname.Add(storageList.GetFileNames()[i]);
}
var byName = from name in filesbyname orderby name.ToString().ToLower() select name;
_LirycListBox.ItemsSource = byName;

private void _LirycListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (_LirycListBox.SelectedItem != null)
{
NavigationService.Navigate(new Uri(string.Format("/EditorSongLiryc.xaml?filename={0}", storageList.GetFileNames()[_LirycListBox.SelectedIndex]), UriKind.Relative));
}
}


No comments:

Post a Comment