Hi guys!
How can I make a single cell read only, preferably by using data binding, but doing it "manually" in code is also ok.I do not want the entire column to be read only, I just need some of the cells in the column to be read only.What I'm trying to do, is bind a collection of objects to a grid (which works just fine), and the objects has properties which can be used to determine if some property should be read only or not...
-Thanks!
Found one solution myself, although I think it's not as elegant as I would like, but it works;
By subscribing to the CellActivating event for the XamDataGrid, I can cancel the activation making the cell read only.
this.xamDataGrid_factDefinition.CellActivating += new EventHandler<CellActivatingEventArgs>(xamDataGrid_factDefinition_CellActivating);
...
Another technique is to bind the IsReadOnly property of the cell's editor via an EditorStyle:
<igDP:Field Name="Name" Label="Task Name"> <igDP:Field.Settings> <igDP:FieldSettings> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamTextEditor}"> <Setter Property="IsReadOnly" Value="{Binding Path=DataItem.IsNameReadOnly}" /> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings></igDP:Field>
Note: IsNameReadOnly is a Boolean property on my data object. Using this approach will still allow the user to select and copy the text in the cell.
Josh