Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
990
pivotgrid no of columns
posted

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,

 

Parents
  • 7922
    posted

    Hi

     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;
            }

     

     Todor

Reply Children