How to add an icon to header cell to difference between editable and read only columns in the gridview

2 posts, 0 answers
  1. Yaxuan
    Yaxuan avatar
    1 posts
    Member since:
    Aug 2015

    Posted 19 Aug 2015 Link to this post


     I have multiple columns in a table, some are editable and some are read only. I want to add show an icon for the header cell to indicate which column is editable.

     If the column is not editable, the icon is hidden.

     Are there any good way to achieve this?

     I have not found any solution yet. It is possible to add an icon to the header cell template, but how do I get the visibility property set based on data column's property IsReadOnly set to true or false? 

  2. Dimitrina
    Dimitrina avatar
    3769 posts

    Posted 24 Aug 2015 Link to this post


    GridViewColumn's Header is an object and you can place any proper control to be displayed as a header. For example you can place a StackPanel with an Image along with TextBlock and apply a converter to its Visibility setting. Since GridViewColumn is not a visual element, its properties cannot be accessed though digging up the visual tree. For the purpose you will need to expose such a property (ReadOnly) in the ViewModel and bind column.IsReadOnlyBinding property to it. Then, bind the Visibility setting to it also.

    Please refer to the documenta
    tion on Read Only Rows and Cells as well as Column Headers documentation for further information on how to redefine it. 

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top