Dears,
Is there any event handler for the pivotgrid scroll?
Thanks,
Hi
There is not scroll event but you can find the scroll bar from control and to listen for thier scroll event. Below is a snippet how to find the scroll bar. The names of the bars you can see from generic.xaml from pivotgrid control template.
void PivotGridContainer_Loaded(object sender, RoutedEventArgs e) { ScrollBar vert = GetObject(PGrid, "VerticalScrollBar") as ScrollBar; ScrollBar horiz = GetObject(PGrid, "HorizontalScrollBar") as ScrollBar; } private DependencyObject GetObject(DependencyObject obj, string name) { DependencyObject child = null; int coutn = VisualTreeHelper.GetChildrenCount(obj); for (int index = 0; index < coutn; index++) { child = VisualTreeHelper.GetChild(obj, index); if (child is FrameworkElement && (child as FrameworkElement).Name == name) { return child; } child = GetObject(child, name); if (child != null) { return child; } } return child; }
ScrollBar vert = GetObject(PGrid, "VerticalScrollBar") as ScrollBar; ScrollBar horiz = GetObject(PGrid, "HorizontalScrollBar") as ScrollBar;
Todor
Hi,
after capturing the scroll of the grid, i want to scroll it to certain point
ScrollBar horiz = GetObject(pivotGrid, "HorizontalScrollBar") as ScrollBar; if (horiz != null) { horiz.Minimum = e.NewRect.X; horiz.Maximum = e.NewRect.X + e.NewRect.Width; }how to regive the grid the new scroll, or attache the grid to this scroll??