Hello All,I have a XamDataGrid with horizontal orientation to which I am adding one record per second. I keep the newest records in view with this statement (placed immediately after the record add):m_myDataGrid.ScrollInfo.ScrollOwner.ScrollToRightEnd();
However, I would like to *not* do this if the user has scrolled back from the right end. How may I check whether or not the control is scrolled all the way to the right?Thanks,Dave
Hello Dave,
You can check the HorizontalOffset/VerticalOffset properties which will give you the current offset of the scrollbar. You can also check the ExtentWidth and ExtentHeight properties which will give you the size of the extent.
Alex,Before posting, I had found these properties and played around with them. The HorizontalOffset never seems to quite equal ExtendWidth. So, I played around with the notion of it being within x% of ExtendWidth. This did not yield satisfactory results either as I have an ever-increasing number of records (I have horizotnal orientation, so that's why I'm interested in horiontal, rather than vertical, scrolling). It's hard to know what the appropriate percent is. I eventually abandoned the idea of using HorizontalOffset and ExtentWidth and started thinking along these lines:If, before adding the new record, the last record is visible, ScrollToRightEnd() after adding the new record (which is now the new last record).It is this approach that I'm working on now.Do you have either suggestions that are more concrete on how to use HorizontalOffset and ExtendWidth or how to implement the approach I'm now taking?Thank you kindly for your time! It is certainly appreciated.Regards,Dave
Dave,
Another thing that comes up in my mind is that you can use the GetRecordsInView(...) method which will give you the ones that are currently in view. From there, you can find out if the last one is amongst them. If it is, this means that you have scrolled to the last record.