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

marcel ethan

Total Post:105

Points:735
Posted by  marcel ethan
C# 
C#
 982  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) { ... }

Answer

NEWSLETTER

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