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
3160
"Object reference not set to an instance of an object." when setting itemssource
posted

pivot grid loads fine the first time (initial load).  When I click refresh (calls refresh method below) it crashes with the error above.

exposuregrid is not null.
exposuregrid.datasource is not null.
exposuregrid.datasource.itemssource is not null.
x is not null.


private void Refresh()
        {
            var x = ViewModel.GetExposureItems(); //returns observable collection
            ExposureGrid.DataSource = (IOlapViewModel)FindResource("FlatData");
            ((FlatDataSource)ExposureGrid.DataSource).ItemsSource = x; // crashes here on first refresh (but not initial load)
}

private void ExposureGrid_Loaded(object sender, RoutedEventArgs e)
{
 ExposureGrid.Loaded -= ExposureGrid_Loaded;

 Refresh();

 ExposureGrid.DataSource.Filters.Add(ExposureGrid.DataSource.CreateFilterViewModel(
 ExposureGrid.DataSource.Cube.Dimensions["PM_Name"].Hierarchies.First()));

 ExposureGrid.DataSource.Filters.Add(ExposureGrid.DataSource.CreateFilterViewModel(
  ExposureGrid.DataSource.Cube.Dimensions["DeliveryDate"].Hierarchies.First()));

 ExposureGrid.DataSource.Filters.Add(ExposureGrid.DataSource.CreateFilterViewModel(
  ExposureGrid.DataSource.Cube.Dimensions["IsFail"].Hierarchies.First()));

 FilterHelper.FilterOption("DeliveryDate", "All", false);
 FilterHelper.FilterOption("IsFail", "All", false);
 FilterHelper.FilterOption("IsFail", "N/A", true);
 OnDeliveryChanged(this, new EventArgs());
 OnPMFilterChanged(this, new EventArgs());
 chkIsNetFails_Click(this, new RoutedEventArgs());
}

 


   at Infragistics.Olap.FlatData.FlatDataFilterSource.OnSelectionChanged()
   at Infragistics.Olap.FilterSource.set_IsSelected(Nullable`1 value)
   at Infragistics.Olap.DataSourceBase.UnregisterFilterSource(IMember member)
   at Infragistics.Olap.FlatData.FlatDataSource.UnregisterFilterSource(IMember member)
   at Infragistics.Olap.DataSourceBase.ReleaseFilterSourceItems(ILevel level, Boolean refreshGrid)
   at Infragistics.Olap.DataSourceBase.UnregisterFilterSource(IFilterViewModel filterViewModel)
   at Infragistics.Olap.DataSourceBase.DetachAreaItemViewModel(IEnumerable`1 items)
   at Infragistics.Olap.DataSourceBase.OnFiltersChanged(NotifyCollectionChangedEventArgs args)
   at Infragistics.Olap.DataSourceBase.OnFiltersChanged(Object sender, NotifyCollectionChangedEventArgs e)
   at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
   at Infragistics.Olap.SwapCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
   at Infragistics.Olap.SwapCollection`1.RemoveItem(Int32 index)
   at System.Collections.ObjectModel.Collection`1.RemoveAt(Int32 index)
   at Infragistics.Olap.SwapCollection`1.ClearItemsInternal(Boolean suppressMessages)
   at Infragistics.Olap.SwapCollection`1.ClearItems()
   at System.Collections.ObjectModel.Collection`1.Clear()
   at Infragistics.Olap.DataSourceBase.ClearAreaItemsCollections()
   at Infragistics.Olap.DataSourceBase.set_Cube(ICube value)
   at Infragistics.Olap.DataSourceBase.DataProviderLoadCubesCompleted(Object sender, LoadCubesCompletedEventArgs e)
   at Infragistics.Olap.DataProviderBase.OnLoadCubesCompleted(LoadCubesCompletedEventArgs args)
   at Infragistics.Olap.FlatData.FlatDataModelProvider.LoadCubesAsync(String catalogName)
   at Infragistics.Olap.DataSourceBase.LoadCubesAsync(String catalogName)
   at Infragistics.Olap.FlatData.FlatDataSource.OnSchemaLoaded(LoadSchemaCompletedEventArgs e)
   at Infragistics.Olap.DataSourceBase.DataProviderLoadSchemaCompleted(Object sender, LoadSchemaCompletedEventArgs e)
   at Infragistics.Olap.DataProviderBase.OnLoadSchemaCompleted(LoadSchemaCompletedEventArgs args)
   at Infragistics.Olap.FlatData.FlatDataModelProvider.LoadSchemaAsync()
   at Infragistics.Olap.FlatData.FlatDataModelProvider.ItemsSourceChanged(Object sender, ItemsSourceChangedEventArgs e)
   at Infragistics.Olap.FlatData.FlatDataConnectionSettings.OnItemsSourceChangedImpl(Object newValue, Object oldValue)
   at Infragistics.Olap.FlatData.FlatDataConnectionSettings.OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
   at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
   at Infragistics.Olap.FlatData.FlatDataConnectionSettings.set_ItemsSource(IEnumerable value)
   at Infragistics.Olap.FlatData.FlatDataSource.set_ItemsSource(IEnumerable value)
   at Poolman.Views.ExposureMatrix.Refresh() in C:\svn_workspace\pool_man\src\Pool.man\Views\ExposureMatrix.xaml.cs:line 118