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
close icon

Style and binding

Hi,

I want to be able to change styling based on bound values. More specific: If I have a row that contain a value from 1 to 100, how do I bind the backgroundcolor of that row such that a value of 1 gives green and the color moves more and more to the red as the value goes to 100 ?

Regards

Morten


3 Replies

SS S. Sridharan Syncfusion Team November 21, 2010 11:17 AM UTC

Hi Morten,

Thanks for using Syncfusion Product.

If you want to set the background colour based on the bound value in XAML, you can use the conditional formatting in which you can set the style for the cells of a particular column based on bound value. You can also apply the background as you requested, in code behind in Model.QueryCellInfo
event handler.
Please find a sample on this in the following location.

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=GridControl1-1918222015.zip

For conditional formatting, already there is an example in our Dash board for this. Please refer the sample in the location.

Sample : $Installation directory\EssentialStudio\\WPF\Grid.WPF\Samples\3.5\WindowsSamples\Grid Data Control - Advanced\Conditional Formatting Demo\CS

Thanks,
Sridharan S.




JF John Fairbanks November 23, 2010 05:23 PM UTC

The problem with the conditional formatting is that you cannot control the style through binding.... for example, you allow me to set the color of a grid cell to "red" if the cell's value is > 100... but I have no way to bind the background color to something. In my case I have a Color property in my row object and I want to bind the Background color to it. The way y'all are doing ti forces me to hard code my business logic inside the XAML unless I want to punt and do things in code behind.



MS Mohamed Suhaib Fahad A. Syncfusion Team December 21, 2010 03:32 PM UTC

Hi John,

We understand your requirements. Right now the grid is implemented with an optimized Style architecture that is different from WPF architecture, this was done because of several performance reasons and that's why we don't have direct manipulation of WPF Style objects. You can create a DirectTrac incident for follow-up, We will take this as a feedback and process it in our future releases.

Thanks,
Fahad


Loader.
Live Chat Icon For mobile
Up arrow icon