diff options
author | Vitaly Takmazov | 2013-01-31 16:47:53 +0400 |
---|---|---|
committer | Vitaly Takmazov | 2013-01-31 16:47:53 +0400 |
commit | fb20dfd7b1529d654c1ec9ad23dda1a427ac648c (patch) | |
tree | ea7f639f980fad33f23bc3b7c72a23a28233d81d /Juick/Classes | |
parent | 56b910c625fadcc712ba735a82a107e2bb0c9c41 (diff) | |
parent | 79317212ed6b3d26c3a2e765b6f58f9d43207f8d (diff) |
Merge branch 'master' of https://bitbucket.org/vitalyster/juick-windowsphone
Diffstat (limited to 'Juick/Classes')
-rw-r--r-- | Juick/Classes/ScrollViewerMonitor.cs | 25 |
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; - } } } |