I am using behaviors to provide custome settings to Xamdatagrid. i want to know how can i set the alternate and selected records background and foregrounds as these are the parts of DataRecordCellArea and CellValuePresenter. i can change them by setting binding on them but in my case i cann't use the binding for them so i need to write the behaviors and set the properties .
can somebody guide me how can i set the altername and selected foreground colors while i already have default style created for my template and need to change the values at runtime by code using behviors.
Hello,
Thank you for your post. I have been looking into it and I can say that you can iterate trough the Records and you can use the CellValuePresenter’s static method FromCell and get the Cell’s CVP. The DataRecordPresenter has FromRecord static method which returns the DRP of the Record and you can use the following code to get the DRCA:
Utilities.GetDescendantFromType(drp, typeof(DataRecordCellArea),true);
Where “drp” is the DRP. After doing this you can set the colors you want. Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.
thanks for valuable feeds. what i am looking is that.
i have create a xamdatagrid and now want to allow my users to set its settings at like allowing alternate rows. alternate foreground , background. etc. for recrods and headers.
i have done with background and alternate background but. the alternate foreground takes a style. which needs to be hooked.
So the question becomes how can i Set the alternate foreground style via code behind and if a user change the color of alternate foreground how it could be setted again. into the views.
I have created a sample project for you with the functionality you want. Basically I created Style for the CellValuePresenter and add DataTrigger in order to change the Foreground only to the Alternated Records. Also I added a Button which changes the Foreground when clicked, by iterating through the Records and change them if they are alternated.
Hope this helps you.