Hello,I read another topic on these forums regarding a way to make certain cells read-only, which was to set the 'IsEnabled' property of the CellValuePresenter to false. However, when I do that there seems to be a gray rectangular border in the cell by default that I'm having trouble figuring out how to get rid of. Is there a simple way to do this or does it involve a lot of work-arounds to make it happen?I'm attaching a screenshot of what it looks like. Some of the cells in the first column will be disabled and should look just like the other columns (no gray border). Thanks in advance for any help you can provide!
Another way would be to cancel the EditModeStarting event by setting the e.Cancel = true for the specific cell.
Alex,While that's true (I tried it), there are a couple of problems with using that method:1) The first column is a numeric ID field. Since some of the cells in that field ARE editable, we have to use a XamComboEditor with the ItemsProvider property set (containing User Names) so that a valid user can be selected. Problem is, cancelling the EditModeStarting event doesn't prevent the ComboBox dropdown arrow from appearing (see image attachment).2) By cancelling EditModeStarting, the UI doesn't accurately reflect that the cell is not editable (i.e. graying out). However, I could live with that if #1 above were solveable.Any thoughts?
This is controlled by the DropDownButtonDisplayMode of the XamComboEditor:
XamComboEditor.DropDownButtonDisplayMode = DropDownButtonDisplayMode.OnlyInEditMode;
It defaults to MouseOver so that is why you are seeing it. Changing it to OnlyInEditMode should resolve this.
Regarding two, you can create a style for the CellValuePresenters and give the user a visual representation that the cell cannot be edited. For example, you can use the Tag property of the Cell and create a DataTrigger that will change the background.
Moreover, if you still want to go with IsEnabled, you can change the behavior of how the element is presented when IsEnabled is false. However, this is controlled by the underlying editor (XamComboEditor, XamTexteditor, etc) and you would have to change the Style triggers for all of them. For example, the XamTextEditor has the folowing style :
<Trigger Property="IsEnabled" Value="False">
<Setter Property="BorderBrush" Value="{DynamicResource {x:Static SystemColors.InactiveBorderBrushKey}}"/>
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" />
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
</Trigger>