Hi,
We're using Infragistics WPF v12.2 (sorry can't upgrade right now).
I'm making a measure editable by adding it in to the EditableMeasures collection when the measure it's added to the PivotGrid's measures collection.
private void MeasuresOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{ switch (e.Action) { case NotifyCollectionChangedAction.Add: foreach (IMeasureViewModel mvm in e.NewItems) { if (mvm.Caption == "Locus" || mvm.Caption == "Cleanup") { PivotGrid.EditSettings.EditableMeasures.Add(mvm.Measure); PivotGrid.DataSource.SetMeasureAggregator(mvm,AggregationHelper.GetDefaultAverageAggregator(typeof(double))); } } break; case NotifyCollectionChangedAction.Remove: foreach (IMeasureViewModel mvm in e.OldItems) { PivotGrid.EditSettings.EditableMeasures.Remove(mvm.Measure); } break; } }
What am I missing?
Thanks.
I have managed to reproduce your issue. I have spent time on it and can say that what is happening is actually expected. When you have set a ContentTemplate property and set the content this content will not be applied unless binding is used. Having in mind that you set a control for content its toString() method is called and full class name is displayed. I have also created a simple project where this is shown with a button control illustrating the same scenario.
Thanks,
M.Yovchev
Answering my last question:
Yes the problem is caused by the DataTemplate applied to the editable cell:
<DataTemplate x:Key="NumericCellTemplate"> <TextBlock Foreground="{Binding Converter={StaticResource NegativeNumberToColorConverter}}" Text="{Binding Converter={StaticResource StringFormatConverter}, ConverterParameter='#,##0.00;(#,##0.00)'}" HorizontalAlignment="Right"/> </DataTemplate>
Do you think the problem is related to how my flatDataSource and grid are set up? Please see below the XAML for both:
<igOlap:FlatDataSource x:Key="FlatDataSource" Rows="[Currency].[Currency], [AdjustmentType].[AdjustmentType]" Measures="USDAmount, LocalAmount,Pnl,NetLocalAmount,RemainLocal,RemainUSD,Locus,Cleanup" Cube="Restricted NDF" > <igOlap:FlatDataSource.CubesSettings> <igOlap:CubeMetadata DataTypeFullName="Item"> <igOlap:DimensionMetadata SourcePropertyName="USDAmount" DisplayName="USD Amount" /> <igOlap:DimensionMetadata SourcePropertyName="LocalAmount" DisplayName="Local Amount" /> <igOlap:DimensionMetadata SourcePropertyName="Pnl" DisplayName="PnL To Trade" DimensionType="Measure"/> <igOlap:DimensionMetadata SourcePropertyName="NetLocalAmount" DisplayName="OCS" DimensionType="Measure"/> <igOlap:DimensionMetadata SourcePropertyName="RemainLocal" DisplayName="Remaining" DimensionType="Measure"/> <igOlap:DimensionMetadata SourcePropertyName="RemainUSD" DisplayName="Remaining (USD)" DimensionType="Measure"/> <igOlap:DimensionMetadata SourcePropertyName="Locus" DisplayName="Locus" DimensionType="Measure" /> <igOlap:DimensionMetadata SourcePropertyName="Cleanup" DisplayName="Cleanup" DimensionType="Measure"/> </igOlap:CubeMetadata> </igOlap:FlatDataSource.CubesSettings> <igOlap:FlatDataSource.HierarchyDescriptors> <igOlap:HierarchyDescriptor SourcePropertyName="Currency" HierarchyName="Currency"> <igOlap:HierarchyDescriptor.LevelDescriptors> <igOlap:HierarchyLevelDescriptor LevelName="Currency" LevelExpressionPath="Currency" /> </igOlap:HierarchyDescriptor.LevelDescriptors> </igOlap:HierarchyDescriptor> <igOlap:HierarchyDescriptor SourcePropertyName="AdjustmentType" HierarchyName="AdjustmentType"> <igOlap:HierarchyDescriptor.LevelDescriptors> <igOlap:HierarchyLevelDescriptor LevelName="AdjustmentType" LevelDisplayName="Type" LevelExpressionPath="AdjustmentType" /> </igOlap:HierarchyDescriptor.LevelDescriptors> </igOlap:HierarchyDescriptor> </igOlap:FlatDataSource.HierarchyDescriptors> </igOlap:FlatDataSource>
<ig:XamPivotGrid x:Name="PivotGrid" AllowCompactLayout="True" DataSource="{StaticResource FlatDataSource}" > <ig:XamPivotGrid.DataCellTemplates> <ig:DataCellTemplate Template="{StaticResource NumericCellTemplate}" ColumnLabel="PnL To Trade"/> <ig:DataCellTemplate Template="{StaticResource NumericCellTemplate}" ColumnLabel="USD Amount"/> <ig:DataCellTemplate Template="{StaticResource NumericCellTemplate}" ColumnLabel="Local Amount"/> <ig:DataCellTemplate Template="{StaticResource NumericCellTemplate}" ColumnLabel="Remaining"/> <ig:DataCellTemplate Template="{StaticResource NumericCellTemplate}" ColumnLabel="OCS"/> <ig:DataCellTemplate Template="{StaticResource NumericCellTemplate}" ColumnLabel="Locus"/> <ig:DataCellTemplate Template="{StaticResource NumericCellTemplate}" ColumnLabel="Cleanup"/> <ig:DataCellTemplate Template="{StaticResource NumericCellTemplate}" ColumnLabel="Remaining (USD)"/> </ig:XamPivotGrid.DataCellTemplates> <ig:XamPivotGrid.ColumnHeaderTemplates> <ig:HeaderTemplate Template="{StaticResource TestDataTemplate}" Label="USD Amount"/> </ig:XamPivotGrid.ColumnHeaderTemplates> <ig:XamPivotGrid.EditSettings> <ig:EditSettings AllowCellEdit="True" /> </ig:XamPivotGrid.EditSettings>
Another difference is that my FlatDataSource's ItemSource is an object of type ICollectionView.
This how it get initialised:
var cvs = CollectionViewSource.GetDefaultView(_items); cvs.Filter = o => { var item = o as Item; return item != null && item.ShowRow; }; DataContext = controller_; PivotGrid.SelectionSettings.CellSelection = PivotSelectionType.Multiple; PivotGrid.DataSource.Measures.CollectionChanged += MeasuresOnCollectionChanged;
_flatDataSource = (FlatDataSource)Resources["FlatDataSource"]; _flatDataSource.ConnectionSettings = new FlatDataConnectionSettings { ItemsSource = cvs };
Regards.
Please refer to the attached sample. I have used your code and it works on my side. You can check also the XAML file but I think yours should be the same.