It almost works until I try to raise an OnPropertyChanged event for the VMs INotifyPropertyChanged implementation. I get:
{"No generic method 'Average' on type 'System.Linq.Enumerable' is compatible with the supplied type arguments and arguments. No type arguments should be provided if the method is non-generic. "}
[System.InvalidOperationException]: {"No generic method 'Average' on type 'System.Linq.Enumerable' is compatible with the supplied type arguments and arguments. No type arguments should be provided if the method is non-generic. "}
Data: {System.Collections.ListDictionaryInternal}
HelpLink: null
InnerException: null
Message: "No generic method 'Average' on type 'System.Linq.Enumerable' is compatible with the supplied type arguments and arguments. No type arguments should be provided if the method is non-generic. "
Source: "System.Core"
StackTrace: " at System.Linq.Expressions.Expression.FindMethod(Type type, String methodName, Type[] typeArgs, Expression[] args, BindingFlags flags)\r\n at System.Linq.Expressions.Expression.Call(Type type, String methodName, Type[] typeArguments, Expression[] arguments)\r\n at Telerik.Windows.Data.Expressions.EnumerableSelectorAggregateFunctionExpressionBuilder.CreateMethodCallExpression(LambdaExpression memberSelectorExpression) in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Core\\Data\\Expressions\\Grouping\\Aggregates\\EnumerableSelectorAggregateFunctionExpressionBuilder.cs:line 48\r\n at Telerik.Windows.Data.Expressions.EnumerableSelectorAggregateFunctionExpressionBuilder.CreateAggregateExpression() in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Core\\Data\\Expressions\\Grouping\\Aggregates\\EnumerableSelectorAggregateFunctionExpressionBuilder.cs:line 30\r\n at Telerik.Windows.Data.EnumerableSelectorAggregateFunction.CreateAggregateExpression(Expression enumerable
Expression) in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Core\\Data\\Data\\Grouping\\Aggregates\\EnumerableSelectorAggregateFunction.cs:line 76\r\n at Telerik.Windows.Data.Expressions.GroupDescriptorExpressionBuilder.<ProjectionPropertyValueExpressions>b__3(AggregateFunction f) in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Core\\Data\\Expressions\\Grouping\\GroupDescriptorExpressionBuilder.cs:line 288\r\n at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()\r\n at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)\r\n at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)\r\n at Telerik.Windows.Data.Expressions.GroupDescriptorExpressionBuilder.CreateProjectionInitExpression() in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Core\\Data\\Expressions\\Grouping\\GroupDescriptorExpressionBuilder.cs:line 279\r\n at Telerik.Windows.Data.Expressions.GroupDescriptorExpressionBuilder.CreateAggregateFunctionsProjectionMemberBin
ding() in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Core\\Data\\Expressions\\Grouping\\GroupDescriptorExpressionBuilder.cs:line 272\r\n at Telerik.Windows.Data.Expressions.GroupDescriptorExpressionBuilder.<CreateMemberBindings>d__0.MoveNext() in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Core\\Data\\Expressions\\Grouping\\GroupDescriptorExpressionBuilder.cs:line 173\r\n at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)\r\n at System.Dynamic.Utils.CollectionExtensions.ToReadOnly[T](IEnumerable`1 enumerable)\r\n at System.Linq.Expressions.Expression.MemberInit(NewExpression newExpression, IEnumerable`1 bindings)\r\n at Telerik.Windows.Data.Expressions.GroupDescriptorExpressionBuilder.CreateSelectBodyExpression() in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Core\\Data\\Expressions\\Grouping\\GroupDescriptorExpressionBuilder.cs:line 161\r\n at Telerik.Windows.Data.Expressions.GroupDescriptorExpressionBuilder.CreateResultSelectorExpressio
n() in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Core\\Data\\Expressions\\Grouping\\GroupDescriptorExpressionBuilder.cs:line 153\r\n at Telerik.Windows.Data.Expressions.GroupDescriptorExpressionBuilder.get_ResultSelectorExpression() in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Core\\Data\\Expressions\\Grouping\\GroupDescriptorExpressionBuilder.cs:line 109\r\n at Telerik.Windows.Data.Expressions.GroupDescriptorExpressionBuilderBase.CreateQuery() in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Core\\Data\\Expressions\\Grouping\\GroupDescriptorExpressionBuilderBase.cs:line 18\r\n at Telerik.Windows.Data.Expressions.GroupDescriptorCollectionExpressionBuilder.CreateQuery() in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Core\\Data\\Expressions\\Grouping\\GroupDescriptorCollectionExpressionBuilder.cs:line 28\r\n at Telerik.Windows.Data.QueryableExtensions.GroupBy(IQueryable source, IEnumerable`1 groupDescriptors) in c:\\Builds\\WPF_Scrum\\Release_WPF\
\Sources\\Development\\Core\\Data\\Collections\\QueryableExtensions.cs:line 184\r\n at Telerik.Windows.Data.QueryableCollectionView.CreateView() in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Core\\Data\\Collections\\QueryableCollectionView.cs:line 480\r\n at Telerik.Windows.Data.QueryableCollectionView.get_QueryableView() in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Core\\Data\\Collections\\QueryableCollectionView.cs:line 511\r\n at Telerik.Windows.Data.QueryableCollectionView.CreateInternalList() in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Core\\Data\\Collections\\QueryableCollectionView.cs:line 575\r\n at Telerik.Windows.Data.QueryableCollectionView.EnsureInternalList() in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Core\\Data\\Collections\\QueryableCollectionView.cs:line 563\r\n at Telerik.Windows.Data.QueryableCollectionView.get_InternalList() in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Core\\Data\\Collections\\Queryab
leCollectionView.cs:line 554\r\n at Telerik.Windows.Data.QueryableCollectionView.GroupedIndexOf(Object item) in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Core\\Data\\Collections\\QueryableCollectionView.cs:line 1499\r\n at Telerik.Windows.Data.QueryableCollectionView.InternalIndexOf(Object item) in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Core\\Data\\Collections\\QueryableCollectionView.cs:line 1491\r\n at Telerik.Windows.Data.QueryableCollectionView.TryRestorePreviousCurrency() in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Core\\Data\\Collections\\QueryableCollectionView.cs:line 847\r\n at Telerik.Windows.Data.QueryableCollectionView.InitializeCurrencyOnRefresh() in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Core\\Data\\Collections\\QueryableCollectionView.cs:line 843\r\n at Telerik.Windows.Data.QueryableCollectionView.RefreshOverride() in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Core\\Data\\Collections\\QueryableCollect
ionView.cs:line 824\r\n at Telerik.Windows.Data.QueryableCollectionView.RefreshInternal() in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Core\\Data\\Collections\\QueryableCollectionView.cs:line 772\r\n at Telerik.Windows.Data.QueryableCollectionView.RefreshOrDefer() in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Core\\Data\\Collections\\QueryableCollectionView.cs:line 767\r\n at Telerik.Windows.Data.QueryableCollectionView.InvalidatePagingAndRefresh() in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Core\\Data\\Collections\\QueryableCollectionView.cs:line 393\r\n at Telerik.Windows.Data.QueryableCollectionView.OnGroupDescriptorsCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e) in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Core\\Data\\Collections\\QueryableCollectionView.cs:line 416\r\n at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)\r\n at Telerik.Windows.Data.R
adObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e) in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Core\\Data\\Collections\\RadObservableCollection.cs:line 143\r\n at Telerik.Windows.Data.ObservableItemCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e) in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Core\\Data\\Collections\\ObservableItemCollection.cs:line 93\r\n at Telerik.Windows.Data.RadObservableCollection`1.InsertItem(Int32 index, T item) in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Core\\Data\\Collections\\RadObservableCollection.cs:line 190\r\n at Telerik.Windows.Controls.Charting.DataBindingHelper.PerformSampling(QueryableCollectionView dataEngine, Int32 samplingThreshold, IEnumerable`1 samplingFunctions) in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Controls\\Chart\\Chart\\Data\\DataBindingHelper.cs:line 759\r\n at Telerik.Windows.Controls.Charting.DataBindingHelper.ProcessNoGrouping(Series
Mapping seriesMapping, QueryableCollectionView dataEngine, Int32 samplingThreshold, ZoomScrollSettings zoomScrollSettings, ISeriesDefinition defaultSeriesDefinition, AxisRangeState axisXRangeState) in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Controls\\Chart\\Chart\\Data\\DataBindingHelper.cs:line 460\r\n at Telerik.Windows.Controls.Charting.DataBindingHelper.ProcessMapping(SeriesMapping seriesMapping, QueryableCollectionView dataEngine, Int32 samplingThreshold, ZoomScrollSettings zoomScrollSettings, ISeriesDefinition defaultSeriesDefinition, AxisRangeState axisXRangeState) in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Controls\\Chart\\Chart\\Data\\DataBindingHelper.cs:line 271\r\n at Telerik.Windows.Controls.Charting.DataBindingHelper.ProcessMappings(SeriesMappingCollection seriesMappings, QueryableCollectionView dataEngine, Int32 samplingThreshold, ZoomScrollSettings zoomScrollSettings, ISeriesDefinition defaultSeriesDefinition, AxisRangeState axisXRangeState) in c:\\Builds
\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Controls\\Chart\\Chart\\Data\\DataBindingHelper.cs:line 245\r\n at Telerik.Windows.Controls.Charting.DataBindingHelper.GenerateDataSeries(Object originalData, SeriesMappingCollection seriesMappings, ISeriesDefinition defaultSeriesDefinition, ChartFilterDescriptorCollection globalFilterDescriptors, ChartSortDescriptorCollection globalSortDescriptors, SamplingSettings samplingSettings, ZoomScrollSettings zoomScrollSettings, AxisRangeState axisXRangeState) in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Controls\\Chart\\Chart\\Data\\DataBindingHelper.cs:line 48\r\n at Telerik.Windows.Controls.RadChart.GenerateDataSeries(Object originalData, SeriesMappingCollection seriesMappings, ChartArea chartArea) in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Controls\\Chart\\Chart\\RadChart.cs:line 1288\r\n at Telerik.Windows.Controls.RadChart.GenerateDataSeries(Object originalData) in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Co
ntrols\\Chart\\Chart\\RadChart.cs:line 1269\r\n at Telerik.Windows.Controls.RadChart.Rebind(Object originalData) in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Controls\\Chart\\Chart\\RadChart.cs:line 894\r\n at Telerik.Windows.Controls.RadChart.Rebind() in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Controls\\Chart\\Chart\\RadChart.cs:line 790\r\n at Telerik.Windows.Controls.Charting.SeriesMapping.RebindChart() in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Controls\\Chart\\Chart\\Data\\SeriesMapping.cs:line 375\r\n at Telerik.Windows.Controls.Charting.SeriesMapping.ManageChangeNotifications(Object originalData, Object oldData) in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Controls\\Chart\\Chart\\Data\\SeriesMapping.cs:line 354\r\n at Telerik.Windows.Controls.Charting.SeriesMapping.ItemsSourcePropertyChanged(DependencyObject target, DependencyPropertyChangedEventArgs args) in c:\\Builds\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Controls\\
Chart\\Chart\\Data\\SeriesMapping.cs:line 331\r\n at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)\r\n at System.Windows.Freezable.OnPropertyChanged(DependencyPropertyChangedEventArgs e)\r\n at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)\r\n at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)\r\n at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp)\r\n at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)\r\n at MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(Int32 k, ICollectionView collectionView, Object newValue, Boolean isASubPropertyChange)\r\n at MS.Internal.Data.PropertyPathWorker.Upd
ateSourceValueState(Int32 k, ICollectionView collectionView)\r\n at MS.Internal.Data.ClrBindingWorker.OnSourcePropertyChanged(Object o, String propName)\r\n at MS.Internal.Data.PropertyPathWorker.System.Windows.IWeakEventListener.ReceiveWeakEvent(Type managerType, Object sender, EventArgs e)\r\n at System.Windows.WeakEventManager.DeliverEventToList(Object sender, EventArgs args, ListenerList list)\r\n at System.ComponentModel.PropertyChangedEventManager.OnPropertyChanged(Object sender, PropertyChangedEventArgs args)\r\n at GenesysShell.DataPointSetViewModel.RaisePropertyChanged(String propertyName) in C:\\Data\\tfs\\...\\MainView.xaml.cs:line 50\r\n at ....DataPointSetViewModel.set_Load(DataView value) in C:\\Data\\tfs\\...\\Views\\MainView.xaml.cs:line 69\r\n at ....MainView.cmdProcess_Click(Object sender, RoutedEventArgs e) in C:\\Data\\tfs\\...\\Views\\MainView.xaml.cs:line 268"
TargetSite: {System.Reflection.MethodInfo FindMethod(System.Type, System.String, System.Type[], System.Linq.Expressions.Expression[], System.Reflection.BindingFlags)}
This thread:
http://www.telerik.com/community/forums/wpf/chart/error-in-aplying-aggregate-function-when-binding-from-datatable.aspx
talks about setting the "FieldType" to double for correcting a similar error, like so:
ItemMapping mapping = new ItemMapping("Sales", DataPointMember.YValue, ChartAggregateFunction.Sum);
mapping.FieldType = typeof(double);
But I'm using wpf design-time binding, not c#--how would this be done in xaml (as I get an error):
<charting:ItemMapping FieldName="Value" DataPointMember="YValue" FieldType="double">
</charting:ItemMapping>
?
My XAML looks like this:
<UserControl ...
<telerik:RadChart x:Name="chartSegTrak" Margin="0,45,0,10" UseDefaultLayout="False">
<charting:ChartArea x:Name="segTrakChartArea" EnableAnimations="False">
</charting:ChartArea>
<telerik:RadChart.SeriesMappings>
<charting:SeriesMapping ChartAreaName="ChartArea" ItemsSource="{Binding Load}">
<charting:SeriesMapping.SeriesDefinition>
<charting:LineSeriesDefinition>
</charting:LineSeriesDefinition>
</charting:SeriesMapping.SeriesDefinition>
<charting:ItemMapping FieldName="Value" DataPointMember="YValue">
</charting:ItemMapping>
</charting:SeriesMapping>
</telerik:RadChart.SeriesMappings>
</telerik:RadChart>
...
The code-behind looks like this:
//
// ViewModel code...
//
public class DataPointSetViewModel : INotifyPropertyChanged
{
private string _name;
public DataPointSetViewModel(){}
public event PropertyChangedEventHandler PropertyChanged;
protected void RaisePropertyChanged(String propertyName)
{
PropertyChangedEventHandler handler = this.PropertyChanged;
if (handler != null)
handler(this, new PropertyChangedEventArgs(propertyName));
}
public DataView Load
{
set
{
_load = value;
RaisePropertyChanged("Load");
}
get
{
return _load;
}
}
...
}
//
// Window/UserControl code...
//
public partial class MainView : UserControl
{
DataPointSetViewModel _vm;
public MainView()
{
_vm = new DataPointSetViewModel();
this.DataContext = _vm;
InitializeComponent();
}
...
private void cmdProcess_Click(object sender, RoutedEventArgs e)
{
...
try
{
...
DataView dvLoad = new DataView(<someclass>.DataSet.GenesysDataPoint);
dvLoad.RowFilter = "StudyId=5 AND GlobalResourceId=2";
dvLoad.Sort = "Year, Month, Day, Hour";
_vm.Load = dvLoad;
}
catch (Exception ex)
{
Cursor = System.Windows.Input.Cursors.Arrow;
MessageBox.Show("Error: " + ex.ToString());
}
}
The UserControl's DataContext is set and I can two-way bind simple properties with success. It's just the DataView two-way binding that's not working correctly. Thanks!