Created
April 4, 2013 16:06
-
-
Save rikkit/5311712 to your computer and use it in GitHub Desktop.
Get the scrollviewer of a WinRT ListView
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static ScrollViewer GetScrollViewer(DependencyObject o) | |
{ | |
// Return the DependencyObject if it is a ScrollViewer | |
if (o is ScrollViewer) | |
{ | |
return o as ScrollViewer; | |
} | |
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(o); i++) | |
{ | |
var child = VisualTreeHelper.GetChild(o, i); | |
var result = GetScrollViewer(child); | |
if (result == null) | |
{ | |
continue; | |
} | |
else | |
{ | |
return result; | |
} | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment