Hi,
My goal is to pass value to every cell in xamdatagrid to Converter. However, I do not know the column names of the DataSource (Datatable) bounded to the grid. XamDataGrid is bounded to DataTable.DefaultView iva view model. I do not know the columns of the datatable.
I have below style defined.
<igWPF:XamDataGrid.Resources> <Style TargetType="{x:Type igWPF:CellValuePresenter}" x:Key="BackGroundStyle"> <Setter Property="Background"> <Setter.Value> <SolidColorBrush Color="{Binding Path=DataItem, Converter={StaticResource BackGroundConverter}}" /> </Setter.Value> </Setter> </Style>
</igWPF:XamDataGrid.Resources>
Code Behind:
private void xamDailyAudit_FieldLayoutInitialized(object sender, Infragistics.Windows.DataPresenter.Events.FieldLayoutInitializedEventArgs e) {
foreach (var field in e.FieldLayout.Fields) { field.Settings.CellValuePresenterStyle = xamDailyAudit.Resources["BackGroundStyle"] as Style; }
}
The issue is, my converter is not firing when Path = DataItem in style. If I add DataItem.columnname in style, then converter fires and cell background changes in XamDataGrid. How can I pass cell value to converter without knowing propertyname or column name.
Hi Vamshi,
Thank you for your post. I have been looking into your requirement and my suggestion is to bind the ‘Background’ property of the CellValuePresenter like e.g.:
<Style TargetType="{x:Type igDP:CellValuePresenter}">
<Setter Property="Background" Value="{Binding Value, RelativeSource={RelativeSource Self}, Converter={StaticResource BackGroundConverter}}"/>
</Style>
This way you are able to access the cell value. I am attaching a sample application(DataGridDataRowTable.zip) that shows my approach.
Let me know, if you need any further assistance on this matter.
Hi, How to pass XamDataGrid's DataSource to ConverterParameter?
In my case, I'm creating a Heat Map using XamDataGrid and applying the background color for each cell based on the cell value. I'm following this method - https://ko.infragistics.com/community/blogs/b/marina_stoyanova/posts/building-a-heatmap-with-wpf-grids
But i would like to calculate Maximum and Minimum of the cell values in order to calculate the background color, for that i need my XamDataGrid's DataSource - HeatMapCollection to be passed as ConverterParameter to my Converter which implements IValueConverter.