Hi,
I am setting background and foreground color on basis of content using DataRecordCellArea style.
i tried it using DataTrgiggers & as well as using converter ( custom value converter ) but it some time work fine, some time not.
for your information i am also sorting record on basis of time, for this i am calling RefreshSortPosition on InitializeRecord event.
one thing i had observed is when i stop sorting. foreground and background color seems to correct, but issue occur when i start sorting as well.
Is style have any connection with record position ?
please help !!
Thanks,
Hello Narender,
The invoking of the "RefreshSortPosition" method in the "InitializeRecord" event handler should not interfere with the colorization.
I modified my previous sample to implement the following:- have a button which adds new records in the data source- invoking of the "RefreshSortPosition" method in the "InitializeRecord" event handler
If you start the application and sort the xamDataGrid by the "Department" column and then try to add new records it looks like the records are being added at the correct location (in terms of sorting) and also with the correct colorization (depending on the "Salary" column).
Can you please modify my sample according to your application so I can observe the issue you are facing ?
Sincerely,Radko KolevSenior Software Developer
Thanks Radko, yes i correctly implemented INotifyPropertyChanged, but actually we are sorting record ( i.e on intialize_record event we are basically calling ResfreshRecordPosition ), what i have noticed that when i stop calling RefreshSortPosition function it work's fine.
so is there any relation bewteen the two ?
thanks,
I am attaching a sample demonstrating how to set foreground and background colors using both converters and data triggers. It is best to use data triggers when you set a color based on an exact value. Converters are better when you need to set a color based on a condition (for example greater than a specific value). Also the sorting seems to be working when clicking on the columns' headers. If your data source's data is constantly changing please make sure you implement correctly the INotifyPropertyChanged interface on your data item's type.
Please let me know if I can be of any further assistance.