I need to style the xamGrid with alternate row colors of black and light gray, plus columns could have their own background color. Currently, I am using TextColumn and adding a CellControl style to set the background color or if no background override the background color is set to transparent. The problem is the alternate row color takes precedence over a column background color. The columns are just text, nothing fancy and I am doing this in code, not xaml.
Hello Bill,
Thank you for your post. I have been looking into it and I can say this is expected, because the Alternate color is set via an animation and it takes precedent over the setter. If you give me more details and a couple of screenshots of the result you want to achieve I would be able to think of a possible workaround for you.
Looking forward for your reply.
This would be a typical style, which actually uses the xamDataGrid. I want to use xamGrid because I need to completely remove the annoying row hover. The only way I was able to do this in the xamDataGrid was to template all of the columns using a TextBlock. But, for this purpose, I need to create the columns in code and I have not been able to figure out how to create a TextBlock style column for the xamDataGrid in code. So, I am up for any solution that provides creating the columns in code, NO row hover, alternate colors, and column background overrides.
I have created a sample project for you with the functionality you want. Basically I copy the default Style of the CellControl and change the Alternate Color. I also remove the animation for the hover color. In order to set the same color for a whole column I handled the XamGrid's CellControlAttached event and there I set the Background to a new color and also the Opacity of the rectangle for the alternate color to 0. Please let me know if you need further assistance on this matter.
Solves the problem I described. Unfortunately, what I did not tell you is that the user needs to be able to modify the background color for a given column, this being a another color or revert back to the black/gray default colors. In addition, the user may decide to included/exclude a column. I need to be able to save the settings and restore on startup. This is the reason I need to create the columns, to handle formatting and hiding.
I have modified the sample I sent you before, so now you are able to change the color or revert it to the base colors. Basically I iterate the Rows and change the colors based on a flag, set when a button is clicked. I also added similar code to the CellControlAttached event, because of the XamGrid's virtualization. In order to be able to hide columns you can turn on the column chooser. I showed you how to do so in the sample. Also you can use our Persistence framework to save/load the settings. Here you can find more details:
http://help.infragistics.com/Help/Doc/Wpf/2012.1/CLR4.0/html/Persistence_About_Infragistics_Control_Persistence_Framework.html
Please let me know if this helps you or you have further questions on this matter.