Hi,
I am building a Silverlight application using Prism 4. An extended version of the Infgragistics DataSourceBase is being used to supply data to a xamPivotGrid as well as other types of visualisation i.e. Column Chart, Bar Chart, Stacked Column etc.
If the data source has been populated with measures, rows or columns and the view is switched to the pivot grid (using Prism's view discovery) the grid fails to initialize with the following error:
{System.NullReferenceException: Object reference not set to an instance of an object. at Infragistics.Controls.Grids.PivotGridLayout.InitializeLayout()}
If the pivot grid is accessed prior to any dimensions or measures being added then it works as expected.
Any advice would be greatly appreciated as this is really holding us up at the moment.
Regards,
Chris
Thanx Todor. I managed to get it working late yesterday evening by calling RefreshGrid() so all is now good.
Kind Regards,
Hi
As a workaround you can use next code. This code will not produce an exception and will work as expect.
private void Button_Click(object sender, RoutedEventArgs e) { var grid = new XamPivotGrid(); grid.SetBinding(XamPivotGrid.DataSourceProperty, new Binding() { Source = this.DataContext, Path = new System.Windows.PropertyPath("DataSource") }); // Add next line grid.DataSource.RefreshGrid(); gridContainer.Content = grid; }
Hi Todor,
FYI - I have managed to suppress the exceptions thrown by calling the below method prior to setting the binding. The only issue is that the actual cell data is not displayed until the data source is next updated. The column and row headers display fine:
grid.UpdateLayout();
This issue can be easily recreated without the need for Prism.
In a view simply have a named ContentControl with a xamPivotDataSelector pointing at a data source. Also place a button in the view. In code behind for the button simply create a xamPivotGrid, bind its data source to the same view model as the data selector and set the content of the ContentControl to the grid. The exact same error is recieved as I have been experiencing:
private void Button_Click(object sender, System.Windows.RoutedEventArgs e) { var grid = new XamPivotGrid(); grid.SetBinding(XamPivotGrid.DataSourceProperty, new Binding() { Source = this.DataContext, Path = new System.Windows.PropertyPath("DataSource") }); gridContainer.Content = grid; }
Please could you investigate and let me know if a) there is a workaround or b) a fix can be made available if no workaround exists.
I think the issue I am facing is different to what you have tested. We are not using the xamPivotDataSelector control in conjunction with the xamPivotGrid. We are manipulating the Columns ,Rows, Filters collections on the data source via custom controls. I think that you could simulate the issue as follows:
Have a xamPivotDataSelector displayed outside of the MainContentRegion and use this control to select a column, measure and row. Then use Prism to navigate toa view which only contains the xamPivotGrid, bound to the same underlying datasource as the data selector control.
I think this would then try to initialise the pivot grid against a pre-populated data source. Would you be able to test this scenario with the Prism quick start?
It is not possible for me to create a simple project showing this but I wll take a look at the Infragistics samples and see if I can recreate the issue another way.
Will let you know how I get on with this.