.net - why listview scrolliintoview is not working? -


I have a list of items and next I have a button I want functionality like this, when I click on the button I'll show items related to the list view at the top of the list. For this I thought that Screintwe would work, but unfortunately it is not working. Any suggestions?

... lstview.SelectedItem = lstview.Items.GetItemAt (lstview.SelectedIndex); Lstview.ScrollIntoView (lstview.SelectedItem); Lstview.UpdateLayout (); .....

The ScrollIntoView method will only show items, if it appears If it is already visible, then the method will not have any effect from the call. In your case, if you are able to click on the item, then the item is in the view and there is no need to scroll. Explanation.

If the object is not visible, then it is aligned above or below the viewport.

If you always want that item to be the first item in the viewport, you must adjust the vertical offset to get the Y value of your ListBox and scroll the scroll viewer to the Y value.

  listBoxScrollViewer.ScrollToVerticalOffset (100); // Measure the Y value of your list box  

You can get the scrollviewer from ListBox like you.


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -