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, 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.
Hi Imran,
Thank you for your replies. I have been looking into your requirement and my suggestion is to apply a style for the XamTextEditor and change its ‘ValueToDisplayTextConverter’ like e.g.:
<Style TargetType="igEditors:XamTextEditor">
<Setter Property="ValueToDisplayTextConverter" Value="{StaticResource TextConverter}"/>
</Style>
…
public class TextConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
if (value != null)
if (value.ToString().Contains("|Changed"))
string newValue = (string)value.ToString().Replace("|Changed", ""); // PROBLEM: I want to remove |CHANGED text from displaying after type conversion has done its job
return newValue;
return value;
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
throw new NotImplementedException();
Let me know, if you need any further assistance on this matter.
Please ignore the previous sample app and use this one.
I had exact situation last week and this example helped me to resolve it.
I uploaded a sample where I am doing the same thing with text value and after conversion I have to remove some text from the cell value. How do I acheive that or which event does help me after firing all typeconverters to change navigate through each cell and change its value, as I want to remove "|changed" text from each cell value after it firing type converter.
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}}"/>
This way you are able to access the cell value. I am attaching a sample application(DataGridDataRowTable.zip) that shows my approach.