IS THERE A WAY HOW CAN I DISABLE LISTBOX REMEMBERING LAST POSITION?

marcel ethan

Total Post:104

Points:728
Posted by  marcel ethan
C# 
C#
 1178  View(s)
Ratings:
Rate this:

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

  1. Pravesh Singh

    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

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!