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,
I have put it like that
public MainPage() { InitializeComponent(); ObservableCollection<Sale> mSharesData = SampleDataGenerator.GenerateSales(500); ((FlatDataSource)this.pivotGrid.DataSource).ItemsSource = mSharesData;
this.pivotGrid.DataSource.ResultChanged += (sender, e) => { Update(); };
this.pivotGrid.Loaded += new RoutedEventHandler(PivotGridContainer_Loaded);
}
any way, if i put it in the update function, it works :)
Hi
It seems that you havent set the datasource when the Loaded event is fired and the panels and scroll bars are not visible. So that is why VisualTreeHelper can not find them.
In this case you can use LayoutLoaded event ot get your visual elements
this.piotGrid.LayoutLoaded += new System.EventHandler<System.EventArgs>(PGrid_LayoutLoaded);
Todor
Hi,
void PivotGridContainer_Loaded(object sender, RoutedEventArgs e) { PivotColumnsPanel obj = GetObject(this.pivotGrid, "ColumnsHeaderPanel") as PivotColumnsPanel; double columnWidth = obj.RenderSize.Width / 12; for (int index = 0; index < 12; index++) { pivotGrid.DataColumns[index].ColumnWidth = columnWidth; } ScrollBar vert = GetObject(pivotGrid, "VerticalScrollBar") as ScrollBar; ScrollBar horiz = GetObject(pivotGrid, "HorizontalScrollBar") as ScrollBar; }
so in my case the object is PivotColumnsPanel andScrollBar.
i tried to call this function PivotGridContainer_Loaded from the pivotGrid_CellControlAttached and it worked, the object returned a value, but i dont want it to be called for each cell, i want it for the whole grid.
What is the type of the 'obj'. You should give the pivotGrid.
It still gives me null value
because the int coutn = VisualTreeHelper.GetChildrenCount(obj);
count is always zero and child = VisualTreeHelper.GetChild(obj, index); is null