4

I have a MT.Dialog where i add some log informations.

Rows can be of different heights.

How can I make sure, that my MT.Dialog always scroll to the bottom, so that the entire last row is always visible?

BUT .... if user scrolls up the list, then it must not scroll to the bottom when adding new rows.

Any suggestions?

Thanks! Mojo

MojoDK
  • 4,410
  • 10
  • 42
  • 80

1 Answers1

7

Hmm, without knowing more about your implementation or root element structure I can only surmise that its top-level only and not nested. That being said....

var lastIndexPath = this.Root.Last()[this.Root.Last().Count-1].IndexPath;
this.TableView.ScrollToRow(lastIndexPath, UITableViewScrollPosition.Middle, true);

...you can simply grab the indexPath of the last row in the array, grab it's index path and scroll the table view down to it programatically.

FYI, the code to get the indexPath is untested, but should work fine. Make sure you have the following defined at the top of your class :-)

using System.Linq;
Anuj
  • 3,134
  • 13
  • 17
  • Great thanks! ... Now I only need to figure out if last row is visible, before firing your code. If user scrolls up the list, then it must not make last row visible. Any idea? – MojoDK Dec 30 '11 at 12:16
  • 1
    Short answer: subclass Element, override GetCell, add state for ScrolledToBottom, and do a do a state management in GetCell. – Anuj Dec 30 '11 at 16:20