We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Converter with bind parameter

Hi,
I've a sfDataGrid with a column MYDATE and colum MYTIMESPAN
I've made a converter on the cell MYDATE to change it adding the MYTIMESPAN cell value, the problem is that I'm no able to pass both values to the converter. With converterparams I can't bind to MYTIMESPAN path because 'Binding' can only be set on a DependencyProperty of a DependencyObject
I've also tried with MultiBindigs but the converter go in loop.
How I can solve this!??

Below you can see my working converter but in this way I've no access to the MYTIMESPAN cell value:

                                <syncfusion:GridTemplateColumn HeaderText="MYDATE " MappingName="MYDATE ">
                                    <syncfusion:GridTemplateColumn.CellTemplate>                                      
                                        <DataTemplate>
                                            <Label>
                                                <Label Content="{Binding Path=MYDATE , Converter={converters:myMYDATEConverter}}" />
                                            </Label>
                                        </DataTemplate>
                                    </syncfusion:GridTemplateColumn.CellTemplate>
                                </syncfusion:GridTemplateColumn>


3 Replies

BR Balamurugan Rajaraman Syncfusion Team March 25, 2017 09:47 AM UTC

Hi Gianni. 

Thank you for contact Syncfusion support. 

We have analyzed your query “Converter with bind parameter”. You can able to achieve your requirement by writing the converter for the Value Binding to the DateTime column as like the below provide code sample. 
C# 
public class converter : IValueConverter 
    { 
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 
        { 
            DateTime today = (value as Date)._Date; 
            long duration = (value as Date).DateTime.Hours; 
            today = today.AddHours(duration); 
            return today; 
        } 
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 
        { 
            throw new NotImplementedException(); 
        } 
 
    } 

Xaml: 

  <syncfusion:SfDataGrid.Columns> 
                <syncfusion:GridDateTimeColumn MappingName="_Date"  ValueBinding="{Binding Converter={StaticResource convert},ConverterParameter=SfDataGrid}" /> 
                <syncfusion:GridTimeSpanColumn MappingName="DateTime"  Format = "hh:mm:ss"/> 
            </syncfusion:SfDataGrid.Columns> 


In this sample we have written the Converter for the DateTime Column in this Converter we have added the TimeSpan value with DateTime value. We have attached the sample for your reference and you can download it from the below location. 


Regards, 
Balamurugan R


UN Unknown Syncfusion Team March 27, 2017 12:32 PM UTC

Great! It work fine! My mistake was to use the converter inside the GridTemplateColumn.
Your support is excellent... and thanks to my good publicity one my customer has purchased your WPF license!


BR Balamurugan Rajaraman Syncfusion Team March 28, 2017 04:50 AM UTC

Hi Gianni, 

Thank you for the update. 

Please let us know further assistance on this. 

Regards, 
Balamurugan R 


Loader.
Live Chat Icon For mobile
Up arrow icon