BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
Hi Michael,
Thank you for Contacting Syncfusion Support.
We have analyzed your query. We cannot pass the row index value directly from DisplayBinding to Converter. However you can achieve your requirement by passing GridCell element in DisplayBinding and get the RowIndex in Converter.
Code Example for Xaml:
<Syncfusion:SfDataGrid x:Name="datagrid" AllowEditing="True" ShowGroupDropArea="True" ItemsSource="{Binding GDCSource}" AllowSorting="True"> <Syncfusion:SfDataGrid.Columns> <Syncfusion:GridTextColumn MappingName="EmployeeName" /> <Syncfusion:GridTextColumn MappingName="EmployeeAge" DisplayBinding="{Binding RelativeSource={RelativeSource AncestorType=Syncfusion:GridCell},Converter={StaticResource customvalueconverter}}" /> <Syncfusion:GridTextColumn MappingName="EmployeeArea"/> <Syncfusion:GridTextColumn MappingName="EmployeeGender"/> <Syncfusion:GridDateTimeColumn MappingName="EmployeeDate"/> </Syncfusion:SfDataGrid.Columns> </Syncfusion:SfDataGrid> |
Code Example for C#:
public class CustomValueConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { var gridCell = value as GridCell; var columnBase = gridCell.ColumnBase as DataColumn;
if(columnBase.RowIndex % 2 != 1 ) return "38"; return "34"; }
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { var gridCell = value as GridCell; var columnBase = gridCell.ColumnBase as DataColumn;
if (columnBase.RowIndex % 2 != 1) return "38"; return "34"; } } |
You can download the sample from the following link:
Sample Link:
http://www.syncfusion.com/downloads/support/forum/120390/ze/WpfSample844597472
Please let us know if you have any query.
Regards,
Elangovan S