Skip to content

Instantly share code, notes, and snippets.

@sandrinodimattia
Created July 23, 2012 07:00
Show Gist options
  • Save sandrinodimattia/3162349 to your computer and use it in GitHub Desktop.
Save sandrinodimattia/3162349 to your computer and use it in GitHub Desktop.
GetScrollbar
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