Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2805
how to change xamdatagrid cell style from text to button according to value
posted

Hi,

 

In one column of our xamdatagrid, it's just for displaying text. If the string is empty, we need to change it as a button so that we can do something. Can we do this?

If yes, how could we do this?

If no, we can also change the text color to trigger mouse down event. How to handle this?

 

Thanks for help.

Parents
  • 30945
    Offline posted

    Hello,

     

    Thank you for your post. I have been looking into your question and I can suggest the following approaches for implementing the appearance that you have described:

     

    1. Use StyleSelector. You can create a style with a button and also create a class that derives from StyleSelector. After that, you can set the CellValuePresentrerStyleSelector property of the FieldSettings of the Field to an instance of the created class. Also you should override the SelectStyle method of that class and in that method, the item parameter will be the value of the cell and the container will be the CellValuePresenter. You can check the value of the cell and return the style that contains the button.
    2. Use Triggers. You can create a style for the CellValuePresenter and add a trigger in the Style.Triggers collection, that sets the Template property of the CellValuePresenter. You can use a DataTrigger and set its Binding to bind to the Value of the cell.

     

    I have created a sample application for you, that shows how you can implement both of those approaches.

     

    Please let me know if you need any further assistance on the matter.

     

    Sincerely,

    Krasimir

    Developer Support Engineer

    Infragistics

    www.infragistics.com/support

    CellTemplcateBasedOnValue.zip
Reply Children