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

Total Post:104

Points:728
C# 
C#
 1258  View(s)
Ratings:
Rate this:

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

  1. Post:412

    Points:2888
    Re: Is there a way how can I disable listbox remembering last position?

    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) { ... }

      Modified On Apr-04-2018 01:41:02 AM

Answer