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.

alternative alternative colours for sfTreefgrid rows

Thread ID:

Created:

Updated:

Platform:

Replies:

131198 Jun 27,2017 02:45 PM Jun 28,2017 12:52 AM UWP 1
loading
Tags: SfTreeGrid
Siju.P.Sukumar
Asked On June 27, 2017 02:45 PM


Hi,

  How can I create alternative colours for sfTreefgrid rows and child collections


SIju

Muthukumar Kalyanasundaram [Syncfusion]
Replied On June 28, 2017 12:52 AM

Hi Siju, 

Thank you for contacting Syncfusion support. 

We have checked your query. You can achieve your requirement by customizing the style of  “TreeGridRowControl” as shown like below code, 
 
Code Snippet: Xaml 
 
<local:StyleConverter x:Key="styleConverter" /> 
<Style TargetType="syncfusion:TreeGridRowControl"> 
    <Setter Property="utils:SetterValueBindingHelper.PropertyBinding"> 
        <Setter.Value> 
            <utils:SetterValueBindingHelper Binding="{Binding Converter={StaticResource styleConverter}, RelativeSource={RelativeSource Self}}" Property="Background" />                   
        </Setter.Value> 
    </Setter> 
</Style> 
 
 
Code Snippet: C# 
 
// based on Nodelevel and RowIndex, you can apply the background color 
internal class StyleConverter : IValueConverter 
{ 
    public object Convert(object value, Type targetType, object parameter, string language) 
    { 
        if((value as TreeGridRowControl).DataRow.Level == 0) 
            return new SolidColorBrush(Colors.SkyBlue); 
        if (((value as TreeGridRowControl).DataRow.RowIndex %2 ==0) && ((value as TreeGridRowControl).DataRow.Level !=0)) 
            return new SolidColorBrush(Color.FromArgb(255, 255, 211, 86)); 
        else if (((value as TreeGridRowControl).DataRow.RowIndex % 2 != 0) && ((value as TreeGridRowControl).DataRow.Level !=0)) 
            return new SolidColorBrush(Colors.Bisque); 
        else 
            return new SolidColorBrush(Color.FromArgb(255, 112, 252, 160));            
    } 
 
    public object ConvertBack(object value, Type targetType, object parameter, string language) 
    { 
        throw new NotImplementedException(); 
    } 
} 
 


Please let us know if you have any query. 

Regards, 
Muthukumar K 


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.

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.

;