summaryrefslogtreecommitdiff
path: root/Juick/Classes
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2013-01-13 18:08:09 +0400
committerGravatar Vitaly Takmazov2013-01-13 18:08:09 +0400
commit0c5aac46b9cd725de31a70c00376567bb02af66b (patch)
tree03ea9ddbba54463702608c2850f3ac8180dd09f2 /Juick/Classes
parent2eea9fd05421bbc32ff6e07d8bb34c7e3a8856bb (diff)
Replace buggy ListBox with ItemsControl+HyperlinkButton, fixes #6
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;
- }
}
}