0

I have a Listbox that bind to an ObservableCollection. In my app, I need to clear this collection in OnNavigatedFrom and read it in OnNavigatedTo to reduced memory.

However, I see that when using StackPanel as ItemsPanelTemplate, Listbox can remember its last view (its seletected item), while VirtualizingStackPanel does not.

So how can I disable this behavior when using StackPanel ?

onmyway133
  • 45,645
  • 31
  • 257
  • 263

1 Answers1

0

It is a common problem, you need to set the Listbox's SelectedIndex to -1

Igor Kulman
  • 16,211
  • 10
  • 57
  • 118