Hello,
When setting the DataSource of the OlapAxis, it throws NullReferenceException.
Here is the code snippet that causes the exception:
var numericYAxis= new NumericYAxis() { LabelSettings = new AxisLabelSettings() { Extent = 55, Location = AxisLabelsLocation.OutsideLeft, IsHitTestVisible = true } }; DataChart.Axes.Add(numericYAxis);
OlapXAxis olapXAxis = new OlapXAxis(); olapXAxis.YAxis = numericYAxis; olapXAxis.Label = "{Label}"; olapXAxis.OlapAxisSource = OlapAxisSource.Rows; olapXAxis.LabelSettings = new AxisLabelSettings(); olapXAxis.LabelSettings.Extent = 35; olapXAxis.LabelSettings.Location = AxisLabelsLocation.OutsideBottom; olapXAxis.DataSource = chartViewModel.OlapViewModel;//Note:OlapViewModel is not null
at Infragistics.Controls.Charts.OlapXAxis.LayoutArranged() at Infragistics.Controls.Charts.OlapAxis.ArrangeLayoutInternal() at Infragistics.Controls.Charts.OlapAxis.DataSourceChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue) at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation) at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet, Boolean isBindingInStyleSetter) at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value) at Infragistics.Controls.Charts.OlapAxis.set_DataSource(IOlapViewModel value) at GoIT.Dashboard.Infrastructure.Controls.Charts.DataChartControl.ResolveXAxis(IChartViewModel chartViewModel)
Is there any way how to fix it?
Thank you
Also I have tried to use the data binding. Please see the code below.
Binding binding = new Binding("OlapViewModel"); olapXAxis.SetBinding(OlapAxis.DataSourceProperty, binding);
In this case the exception is : cannot change observablecollection during a collectionchanged or propertychanged event
at System.Collections.ObjectModel.ObservableCollection`1.CheckReentrancy() at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item) at System.Collections.ObjectModel.Collection`1.Add(T item) at Infragistics.Controls.Charts.OlapXAxis.SetCategoryAxis() at Infragistics.Controls.Charts.OlapAxis.BuildSeries() at Infragistics.Controls.Charts.OlapAxis.ArrangeLayoutInternal() at Infragistics.Controls.Charts.OlapAxis.DataSourceChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue) at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation) at System.Windows.DependencyObject.RefreshBLOCKED EXPRESSION
Thank you for your post. I have been looking into the issue that you have described and I could not managed to reproduce it. I have created a sample application in order to test the behavior and I have tested it using the RTM, latest service release and the latest internal build of version 12.1 and when I run the sample application, no exception is appearing. I am attaching the sample application that I have created.
Would you please let me know if you can reproduce the same behavior with my sample application and if not, would you please modify the sample application in order to demonstrates the issue?
Looking forward to hearing from you.
Sincerely,
Krasimir
Developer Support Engineer
Infragistics
www.infragistics.com/support