Created
July 23, 2012 07:00
-
-
Save sandrinodimattia/3162349 to your computer and use it in GitHub Desktop.
GetScrollbar
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
private static ScrollBar GetScrollbar(this DependencyObject dep, string name) | |
{ | |
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(dep); i++) | |
{ | |
var child = VisualTreeHelper.GetChild(dep, i); | |
if (child != null && child is ScrollBar && ((ScrollBar)child).Name == name) | |
return child as ScrollBar; | |
else | |
{ | |
ScrollBar sub = GetScrollbar(child, name); | |
if (sub != null) | |
return sub; | |
} | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment