Styling cell depending on IsReadOnly

3 posts, 0 answers
  1. Stan
    Stan avatar
    11 posts
    Member since:
    May 2010

    Posted 13 Apr 2011 Link to this post

    Hi there

    I have a TreeListView that have columns that are editable and columns that are readonly. I set the background color to grey for the readonly columns but the background of the expander section and indents on the rows are not being set.

    This is the xaml:

    <telerik:GridViewDataColumn DataMemberBinding="{Binding Key}" Header="Task ID" IsReadOnly="True" IsFilterable="False" Background="LightGray"/>

    Attached is a screenshot of the issue. Any ideas how I can style the indents/expanders too?
    Thanks for your help.
  2. Vanya Pavlova
    Vanya Pavlova avatar
    2019 posts

    Posted 14 Apr 2011 Link to this post

    Hello Stan,

    Indeed the behavior you get is the expected one. Due to the Template Structure of TreeListViewRow the only way you may change the background of the expanders in each row is by editing the template of TreeListViewRow. In this case you need to ensure that always the first column should be readonly and apply the desired background. On the other hand you may change the DisplayIndex property of the readonly columns and you do not need to edit the template of TreeListViewRow, please refer to the following snippet:

    <telerik:RadTreeListView  AutoGenerateColumns="False" Margin="40,16,16,112" ItemsSource="{Binding Collection}">
                    <telerik:TreeListViewTableDefinition ItemsSource="{Binding Collection}"/>
                        <telerik:GridViewDataColumn Background="LightGray"  IsReadOnly="True" Header="P1" DisplayIndex="1" DataMemberBinding="{Binding Property1}"/>
                        <telerik:GridViewDataColumn Header="P2" DataMemberBinding="{Binding Property2}"/>
                        <telerik:GridViewDataColumn Header="P3" DataMemberBinding="{Binding Property3}"/>
                        <telerik:GridViewDataColumn Header="P4" DataMemberBinding="{Binding Property4}"/>

    In my opinion the second approach is the recommended one, because there is an indentation in each row which is internally handled.

    Please let me know how this works for you!

    Vanya Pavlova
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  3. Stan
    Stan avatar
    11 posts
    Member since:
    May 2010

    Posted 14 Apr 2011 Link to this post

    Hi Vanya

    Setting the displayindex of the first column to 1 doesn't seem to have solved my issue. The expander background and hierachy indent background still remains white.

    Can you advise?
Back to Top