Hi
I have a XamGrid to which I have bound a collection which has a list of dates. What I want is to automatically scroll to the date (In the XamGrid) which is >= today's date. How can this be done. Can this also be done using MVVM approach. If so, kindly let me know with a sample.
Thanks,
Chev
Hello Chev,
Thank you for your post. I have been looking into it and I created a sample project for you with the functionality you want. Basically I called the XamGrid’s ScrollCellIntoView method in the XamGrid’s Loaded event handler in order to scroll to today date. If you don’t want to do this in code behind you can use Interactions. Here it is explained how to use them:
http://www.codeproject.com/Articles/125188/Using-EventTrigger-in-XAML-for-MVVM-No-Code-Behind
Please let me know if you have further questions on this matter.
Looking forward for your reply.
Great. This works.
I have another question. What I want is whenver the itemssource changes on my xamgrid I would like this event to occur (Scroll). Also, kindly help me in giving a sample which shows how this can be done without code behind.
Edited: The scroll works fine but is it possible to scroll in such a way that the selected row is shown as the first row in the grid?
Thanks
Hello Ranjith,
Once you follow the approach I suggested you in order to make the scrolling in MVVM way you can execute the code for scrolling after the code that changes the data source. AS for the scrolling itself, currently it scrolls to the record until it became visible, so if the record is below the visible area it will become the last record, if it is above the visible are it will be the first row.
Hope this helps you.