Home Forums WPF controls Xceed DataGrid for WPF Style a ReadOnly Column

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #26045 |

    Is there a simple way to change the background colour of a cell if it appears in a readonly column? I’ve tried using style triggers on the datacell like so:

    <Style TargetType=”{x:Type xcdg:DataCell}”>
    <Style.Triggers>
    <Trigger Property=”ReadOnly” Value=”True”>
    <Setter Property=”Background” Value=”Red” />
    </Trigger>
    </Style.Triggers>
    </Style>
    The problem with this is that the cell’s readonly property is not necessarily true if the column is ReadOnly. I noticed this because all my columns are readonly=true but when I set the cell’s style readonly trigger value to false, all my cells turn red. I tried a DataTrigger Binding with FindAncestor Column but that didn’t seem to work, quite possibly my own fault.
    I’d appreciate any help or suggestions.
    Thanks.

    Imported from legacy forums. Posted by pin_monkey12 (had 2046 views)

    Xceed Support
    Member
    Post count: 5658

    What you could use is a DataTrigger that looks as follows:

    <DataTrigger Binding=”{Binding RelativeSource={RelativeSource Self}, Path=ParentColumn.ReadOnly}” />

    The ParentColumn property can be used to accesst the parent column of any cell.

    Imported from legacy forums. Posted by Marcus [Xceed] (had 3249 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.