Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

horizontal offset for scrollviewer in gridview C#

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

like image 780
Raj Kumar Avatar asked Dec 12 '22 23:12

Raj Kumar


1 Answers

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.

like image 152
Filip Skakun Avatar answered Dec 25 '22 08:12

Filip Skakun