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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Is it possible to change RowHeader Style ?

Thread ID:

Created:

Updated:

Platform:

Replies:

129464 Mar 20,2017 04:00 PM UTC Mar 24,2017 03:59 AM UTC WPF 5
loading
Tags: SfDataGrid
Silvio
Asked On March 20, 2017 04:00 PM UTC

Hi,

I would like to better show to the user when a record in a datagrid has been changed.
It should be nice for me, for example, to draw a red background color all the row Headers of all the records that have been changed.
I already have in the model record a bool property that identifies if the relative record has been changed.
So I ask you if it's possible to change the row Header style of each row according to the change status of the related binded record.
Thank you,

Silvio

Jai Ganesh S [Syncfusion]
Replied On March 21, 2017 11:36 AM UTC

Hi Silvio, 
You can change the background color of RowHeader when the record property changed by write the style for GridRowHeaderCell,  
<Style  TargetType= "syncfusion:GridRowHeaderCell"> 
   <Setter Property="Background" Value="{Binding Status,Converter={StaticResource converter }}"/> 
 </Style> 
 
public class CustomConverter:IValueConverter 
{ 
    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 
    { 
        bool statusvalue = (bool)value; 
        if (statusvalue == true) 
            return Brushes.Red; 
        else 
            return Brushes.Green; 
 
        return value; 
    } 
 
    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 
    { 
        throw new NotImplementedException(); 
    } 
} 
 
In the above sample, we have changed the RowHeader background based on the Status column value. 
Reference: 
Regards, 
Jai Ganesh S 


Silvio
Replied On March 21, 2017 12:02 PM UTC

Thank you Ganesh for your answer.

This is good if you don't use SfSkinManager for grid styles.
If instead you use it, your sugestion seems not to work.
Please find here attached the same your example that I have changed applying a Blend Style to the whole window.
I'd like the red background appears only when the record is changed, otherwise I'd like the standard Blend background is applied.
But, as you can see, in this example Blend background is always applied.
What changes have I to make in order to let it work as I'd like ?
Thank you.

Silvio

Attachment: BackgroundColorForRowHeader_f44158a5.zip

Jai Ganesh S [Syncfusion]
Replied On March 22, 2017 06:00 PM UTC

Hi Silvo, 
The already applied styles (setting in App.Xaml) are disabled while applying the theme through SfSkiManager in code behind. You can overcome this by setting a theme in xaml instead of code behind like below, 
<ResourceDictionary> 
            <ResourceDictionary.MergedDictionaries> 
                <ResourceDictionary Source="/Syncfusion.Themes.Blend.WPF;Component/SfDataGrid/SfDataGrid.xaml"/> 
            </ResourceDictionary.MergedDictionaries> 
 
            <local:CustomConverter x:Key="converter"/> 
            <Style TargetType= "syncfusion:GridRowHeaderCell"> 
                <!--By using converter the Background color is changed based on the business logic--> 
                <Setter Property="Background" Value="{Binding Status,Converter={StaticResource converter }}"/> 
            </Style> 
</ResourceDictionary> 
 
Regards, 
Jai Ganesh S 


Silvio
Replied On March 23, 2017 08:34 AM UTC

Thank you very much for your help, Ganesh!

Jai Ganesh S [Syncfusion]
Replied On March 24, 2017 03:59 AM UTC

Hi Silvo,  
Thank you for the update. 
Please let us know if you need further assistance on this. 
Regards, 
Jai Ganesh S 


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

;