Home > DeveloperSection > Forums > Is there a way how can I disable listbox remembering last position?
marcel ethan
marcel ethan

Total Post:105

Points:735
Posted on    January-23-2014 12:00 AM

 C# C# 
Ratings:


 1 Reply(s)
 740  View(s)
Rate this:

Is there a way how can I disable listbox remembering last position?



Pravesh Singh

Total Post:411

Points:2881
Posted on    January-23-2014 1:02 AM

Hi Marcel,

The following code scrolls to the first item, when you navigate to the view:

protected override void OnNavigatedTo(NavigationEventArgs e)

{

    var firstListBoxItem = listBox.Items.FirstOrDefault();

    if (firstListBoxItem != null) listBox.ScrollIntoView(firstListBoxItem);

}

You may extend it by e.g. checking whether you are actually navigation backwards by using if(e.NavigationMode == NavigationMode.Back) { ... }


Don't want to miss updates? Please click the below button!

Follow MindStick