mvvm how to make a list view auto scroll to a new Item in a list view

后端 未结 5 776
南旧
南旧 2020-12-03 05:19

I am using the MVVM pattern, I have a view which creates a new ViewModel, after the user clicks save, this view is closed and a seperate view is opened which di

5条回答
  •  醉酒成梦
    2020-12-03 05:48

    hmm talk about overkill, for a more simple approach and the one i imagine most will use....

    for listview simply whack in:

    listView1.EnsureVisible(listView1.Items.Count - 1);
    

    And for Listbox simply whack in:

    listBox1.SelectedIndex = listBox1.Items.Count - 1; 
    listBox1.SelectedIndex = -1;
    

    To your listview item add (..etc) method... .. or whack it on a timer tick.

    The above way under OP seems to much to do for me i am lazy... All code explains its self.

提交回复
热议问题