I'm trying to highlight the playing song from a listview, and running into some trouble. Often, lvicurrent is null. Here is my code...
private void highlightItem(String focused)
{
//songlistView.ItemContainerGenerator.ItemsChanged????;
ListViewItem lvicurrent = new ListViewItem();
if (lviPrevious != null)
{
lviPrevious.Background = new SolidColorBrush();
}
if (focused.Equals("songListview"))
{
lvicurrent = songlistView.ItemContainerGenerator.ContainerFromIndex(songIndex) as ListViewItem;
lviPrevious = lvicurrent;
lvicurrent.Background = new SolidColorBrush(Colors.LightGreen);
}
else if (focused.Equals("playListview"))
{
lvicurrent = playlistView.ItemContainerGenerator.ContainerFromIndex(songIndex) as ListViewItem;
lviPrevious = lvicurrent;
lvicurrent.Background = new SolidColorBrush(Colors.LightGreen);
}
}
private void StatusChangedEventHandler(object sender, EventArgs e)
{
}
Only thing I could find on the internet is wait for the status to be finished, but there is no status property in winrt as far as I can tell.
My other problem is that more than 1 song is being displayed in green. I don't know why this is, maybe because it's a virtualizing stackpanel... but then one would think it would not affect songs not currently visible in the stackpanel. This is the very last thing I need to fix before I publish the app.