Home Forums WPF controls Xceed DataGrid for WPF making certain cells readonly

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

    I’ve been digging through docs and samples and posts for a while now, and haven’t found the answer I’m looking for. My property is an enum, and some of the values can be modified, but others are fixed and unchangable. For the unchangable items, I’d prefer if the cell behaved exactly like a readonly cell.

    I’m guessing I’ll probably have to write an enum to boolean converter, but I’m not sure what to convert and where. I’m using a DataGridCollectionView and version 2.0.

    Thanks for helping a new user.

    Imported from legacy forums. Posted by Thomas (had 2288 views)

    Xceed Support
    Member
    Post count: 5658

    You can create an implicity style that targets DataCell and that has a DataTrigger that checks the value you want and sets the ReadOnly property to true when your criteria is met.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 150 views)

    User (Old forums)
    Member
    Post count: 23064

    Thank you! After looking at the EditorControls sample, I came up with this, in case it helps anyone else.

    <pre>
    <Window.Resources>
    <Style TargetType=”{x:Type xcdg:DataCell}”>
    <Style.Triggers>
    <DataTrigger Binding=”{Binding RelativeSource={RelativeSource Self}, Path=ParentRow.DataContext.IsNon}”
    Value=”True”>
    <Setter Property=”ReadOnly” Value=”True” />
    </DataTrigger>
    </Style.Triggers>
    </Style>
    </Window.Resources>
    </pre>
    I was lazy and added a calculated property to my class instead of writing the converter.

    Imported from legacy forums. Posted by Thomas (had 3637 views)

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