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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to pass the current binded datagrid item to the converter when using a conditional formatting

Thread ID:

Created:

Updated:

Platform:

Replies:

132373 Aug 29,2017 06:41 AM Aug 31,2017 12:46 AM WPF 3
loading
Tags: SfDataGrid
Silvio
Asked On August 29, 2017 06:41 AM

Hi,

I'm analyzing your example named "Conditional Formatting Demo" in your online documentation on SfDatagrid control.
I'd like to implement a user interface where, for a particular column, the backgound color is changed according to some condition.
Your example is very good and uses a Converter that can calculate the correct background color related to the value of the associated cell but uses only the cell value without any parameter.
But, to decide witch color to return in my converter, I'd need not only the value of the cell but also other properties that belong to the current binded record of the currently displayed row.
So I need to pass an object parameter to that converter that should let me have access to the whole record binded to the row it is currently displayed.
How can I pass such a parameter to my converter?
Thank you.

Silvio

Balamurugan Rajaraman [Syncfusion]
Replied On August 30, 2017 11:27 AM

Hi Silvio, 
 
Thanks for contacting Syncfusion support. 
 
We have checked your query “How to pass additional parameter to the converter”. You can able to achieve your requirement using the MuliBinding concept by this way you can able to pass the additional parameter to the converter. Here we have passed the cell value and with additionally pass the collection of the particular row in to the converter as like the below code sample.  
 
<Window.Resources> 
        <local:ViewModel x:Key="viewmodel" /> 
        <local:CustomRowStyleMultiValueConverter x:Key="CustomRowStyleMultiValueConverter" /> 
        <Style x:Key="stylecolor" TargetType="Syncfusion:VirtualizingCellsControl"> 
            <Setter Property="Background"> 
                <Setter.Value> 
                    <MultiBinding Converter="{StaticResource CustomRowStyleMultiValueConverter}"> 
                        <Binding Path="IsChecked" /> 
                        <Binding RelativeSource="{RelativeSource Self}" /> 
                    </MultiBinding> 
                </Setter.Value> 
            </Setter> 
        </Style> 
    </Window.Resources> 

we have created sample as per the requirement and attached that sample for your reference. You can able to get it from the below link
 
 
 
Pease refer the below link for getting more information regarding this 
 
Regards, 
Balamurugan R 


Silvio
Replied On August 30, 2017 12:54 PM

Dear Balamurugan,


thank you very much for your very precious help!

MultiBinding was exactly what I needed.


Silvio Scattaglia


Balamurugan Rajaraman [Syncfusion]
Replied On August 31, 2017 12:46 AM

Hi Silvio, 
 
Thanks for the update, 
 
Please let us know if need any further assist on this. 
 
Regards, 
Balamurugan R 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;