I'm developing metro app using Windows 8 release preview and C#(VS 2012), Is there any way to scroll grid view horizontal scroll bar by providing HorizantalOffset.
Brief: In scroll-viewer class we can move horizontal scroll bar and vertical scroll bar dynamically using ScrollToHorizontalOffset
and ScrollToVerticalOffset
,But in gridview I don't find those properties, So how can I scroll dynamically by code? or can i get reference to scrollbar in gridview ? Can any one help me with this, Thanks in advance
You can get the reference to the ScrollViewer from the GridView's template using VisualTreeHelper. You can also use some helper methods I put in WinRT XAML Toolkit - in VisualTreeHelperExtensions. You would just need to add
using WinRTXamlToolkit.Extensions;
then call
var scrollViewer = myGridView.GetFirstDescendantOfType<ScrollViewer>()
and there you go.
EDIT* - note the namespace has changed in later versions of the toolkit to WinRTXamlToolkit.Controls.Extensions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With