Hello,
I have following problem. In Infragisitcs UltraGrid for WinForms it was possible to enter edit mode for properties without a setter, so that You can copy part of the text but You cannot modify it.
Currently I am working on WPF app with MVVM and want to archive similar behavior, however looks like it it only possible when we add empty setter and readonly propery of TextField To true. I want to keep the code clean so empty setters are not designated. Is there Any other way to work it around?
XAML:
<igDP:XamDataGrid> <igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout> <igDP:FieldLayout.Settings> <igDP:FieldLayoutSettings SelectionTypeField="Range" SelectionTypeCell="Default" SelectionTypeRecord="Default"/> </igDP:FieldLayout.Settings> <igDP:TextField Name="TestProperty" AllowRecordFiltering="True" Label="{x:Static properties:Resources.TestPropertyName}"> <igDP:TextField.Settings> <igDP:FieldSettings EditorType="{x:Type igEditors:XamTextEditor}"> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamTextEditor}"> <Setter Property="IsReadOnly" Value="True"/> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:TextField.Settings> </igDP:TextField> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts> </igDP:XamDataGrid>
Scenario 1.
Model:
public string TestProperty { get => testProperty; set => SetProperty(ref testProperty, newValue); }
result
Can Enter Edit mode but cannot modify text or change but possible to select part of the text
Scenario 2.
public string TestProperty{get => testProperty;}
Can Select Cell but cannot Enter Edit mode or select part of the cell text
Hello Mikolaj,
I have been investigating into the behavior you are seeing, and the behavior that you are seeing is currently the expected behavior with the XamDataGrid. If a property does not have a setter, it will not be able to enter edit mode as there is nothing to be edited. I understand that the UltraGrid works differently in this case, but the UltraGrid is a different control with a different API.
The best thing I can recommend is essentially what you have already mentioned. You need to add a setter to your property and then mark the editor read only. This will allow you to enter edit mode, but not actually edit anything.
Please let me know if you have any other questions or concerns on this matter.
Thanks Andrew, that fully answers my question.