Dears,
i am not setting the width of the pivotgrid because i want it to take the size of the web page,
but how to set the numbers of columns viewed to exactly 12, and the user can scroll, but i want him to c only 12 at a time.
how can i do that?
Thanks,
Hi
Sorry for misunderstanding this is an event handler of XamPivotGrid’s Loaded event. I mean
XamPivotGrid pivotGrid;
this. pivotGrid.Loaded += new RoutedEventHandler(PivotGridContainer_Loaded);
Todor
I tried to call the function PivotGridContainer_Loaded from
this.Loaded += PivotGridContainer_Loaded; which is in the mainpage function and after initialize components and after giving the grid the datasouce
when i debug, the gird is not null while the PivotColumnsPanel obj is null
You can set columns width. First you should find the width of columns panel and divide it to 12 to find the one column width and then set it to column See snippet below.
void PivotGridContainer_Loaded(object sender, RoutedEventArgs e) { PivotColumnsPanel obj = GetObject(PGrid, "ColumnsHeaderPanel") as PivotColumnsPanel; double columnWidth = obj.RenderSize.Width / 12; for (int index = 0; index < 12; index++) { PGrid.DataColumns[index].ColumnWidth = columnWidth; } } 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; }