summaryrefslogtreecommitdiff
path: root/Juick/Classes
diff options
context:
space:
mode:
Diffstat (limited to 'Juick/Classes')
-rw-r--r--Juick/Classes/ScrollViewerMonitor.cs25
1 files changed, 1 insertions, 24 deletions
diff --git a/Juick/Classes/ScrollViewerMonitor.cs b/Juick/Classes/ScrollViewerMonitor.cs
index 6a65773..a985360 100644
--- a/Juick/Classes/ScrollViewerMonitor.cs
+++ b/Juick/Classes/ScrollViewerMonitor.cs
@@ -37,7 +37,7 @@ namespace Juick.Classes
{
var element = (FrameworkElement)sender;
element.Loaded -= element_Loaded;
- var scrollViewer = FindChildOfType<ScrollViewer>(element);
+ var scrollViewer = (ScrollViewer)element.Parent;
if (scrollViewer == null)
{
throw new InvalidOperationException("ScrollViewer not found.");
@@ -59,28 +59,5 @@ namespace Juick.Classes
var binding = new Binding("VerticalOffset") { Source = scrollViewer };
listener.Attach(scrollViewer, binding);
}
-
- static T FindChildOfType<T>(DependencyObject root)
- where T : class
- {
- var queue = new Queue<DependencyObject>();
- queue.Enqueue(root);
-
- while (queue.Count > 0)
- {
- var current = queue.Dequeue();
- for (int i = VisualTreeHelper.GetChildrenCount(current) - 1; 0 <= i; i--)
- {
- var child = VisualTreeHelper.GetChild(current, i);
- var typedChild = child as T;
- if (typedChild != null)
- {
- return typedChild;
- }
- queue.Enqueue(child);
- }
- }
- return null;
- }
}
}